Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Email
Message
 
À
06/08/2005 12:46:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Re: Email
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000 SP4
Divers
Thread ID:
01037177
Message ID:
01039098
Vues:
26
Hi Ronald,

Here's the code, taken straight from a method in the app where I'm using blat.

I hope this helps with your problem. There are parts of it that you obviously don't need, but the core should be useful for you.

Alex
Lparameters tlCritical

LOCAL lcDll, lcCmd, lnResult
Local lcRecipients, lcErrorEmail
Local lcSMTPServer
Local liCurrentLevel
Local liLevel
Local lcSubject
Local lcLogEntry

If Pcount() = 0
	tlCritical = .f.
Else
	If Vartype( tlCritical) <> "L"
		tlCritical = .f.
	endif
Endif

lcRecipients = ThisForm.oIni.GetIniEntry( "Main", "EmailTo", ThisForm.cIniFile)
lcSMTPServer = ThisForm.oIni.GetIniEntry( "Main", "SMTPServer", ThisForm.cIniFile)

lcDll = ThisForm.cAppPath + "\blat.dll"

DECLARE INTEGER Send IN (lcDll) STRING blatstring

* Prepare message body
lcErrorEmail = "Hello, " + CRLF ;
	+ CRLF ;
	+ "The following is information related to the creation of the radar.web update on " ;
	+ Dtoc( Date()) + " at "+ Alltrim( Time()) + ":" + CRLF ;
	+ CRLF ;
	+ "Message: " + ThisForm.oResult.Message + CRLF ;
	+ "Offending code (if any): " ;
	+ CRLF ;
	+ ThisForm.oResult.LineContents + CRLF + CRLF + CRLF ;
	+ CRLF + CRLF ;
	+ "Call stack: " + CRLF + CRLF
	
For liLevel = 1 To Program( -1)
	lcErrorEmail = lcErrorEmail + Program( liLevel) + CRLF
Next
	lcErrorEmail = lcErrorEmail + CRLF + CRLF ;
	+ CRLF + CRLF ;
	+ "End of message."

StrToFile( lcErrorEmail, ThisForm.cAppPath + "\email.txt")

* I want the subject to change from one message to another so that gmail doesn't clump them together.
lcSubject = "RACWeb information " + Left(Dtos(Date()), 8) + "-" ;
	+ right( Ttoc( Datetime(), 1), 6)
lcCmd = ["] + ThisForm.cAppPath + [\email.txt" -s "] + lcSubject  + [" -t ] + lcRecipients ;
	+ [ -server ] + lcSMTPServer + [ -f RacWebUpdate@record-access.com]  ;
	+ [ -log "] + ThisForm.cAppPath + [\blat.log" -superdebugT]


lnResult = Send(lcCmd)

lcLogEntry = "Command: " + lcCmd + CRLF + CRLF + Replicate( "-", 60) + CRLF ;
	+ "Message: " + Filetostr( ThisForm.cAppPath + "\email.txt") + CRLF + CRLF + Replicate( "-", 60) ;
	+ CRLF ;
	+ "Result code: " + Alltrim( Str( lnResult)) + CRLF
	
ThisForm.log.new( "Email sent to " + lcRecipients, lcLogEntry)

If tlCritical
	* The error was of a critical nature. The app must be shut down.
	Wait "Closing application in 10 seconds" Window Noclear Timeout 10
	Thisform.Release()
Endif

* Now that the error has been emailed. Clear the contents of the oResult properties.
ThisForm.oResult.errorno = 0
ThisForm.oResult.message = ""
ThisForm.oResult.Comment = ""

Return .t.
>Alex,
>
>Thanks for responding. I've tried what you suggested(Blat), in fact I've tried several of them, and I consistently get the error: result = 1. That is that my body is "bad" or not submitted. I've tried submitting my body everyway possible; with a -; with a -body; as a file and as text(even butt up). All return the same results which is not 0!
>
>Below is the lcCmd variable value I've used:
>
>lcCmd = 'wikibody.txt -u cherry -pw cherry69 -t debra@roncherry.com -s "VFP email" -f cherry@roncherry.com -server mail.roncherry.com'
>
>See anything that needs correcting? Any further suggestions?
Low-carb diet not working? Try the Low-food diet instead!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform