West Wind Internet Protocols 4.68 |
| Sending SMTP Email |
Regardless of the mode you use the syntax for using the mail functionality is the same:
LOCAL loSMTP as wwIPStuff loSmtp=CREATEOBJECT("wwIPStuff") loSmtp.cMailServer="mail.yourmailserver.net" loSmtp.cSenderEmail="rstrahl@west-wind.com" loSmtp.cSenderName="Rick Strahl" *** Optional Username * loSmtp.cUsername = "ricks" * loSmtp.cPassword = "secret" loSmtp.cRecipient="somebody@sweat.com,another@bust.com" loSmtp.cCCList="rstrahl@east-wind.com,looser@nobody.com" loSmtp.cBCCList="fred@flintstone.com" loSmtp.cSubject="wwIPStuff Test Message" loSmtp.cMessage="Who said this had to be difficult?" * loSmtp.cContentType = "text/html" && Optionally send HTML content * loSmtp.cAttachment="c:\temp\somefile.pdf,c:\temp\another.txt" && Optionally send file attachments llResult = loSmtp.SendMail() IF !llResult Wait window loSmtp.cErrorMsg ENDIF
You can also send messages Asynchronously:
*** Optionally send Asynchronous without waiting for a result loSmtp.SendMailAsync()
Note that when you send messages asynchronously, you get no result code or other indication whether the mail sending was a success.
IF !loSmtp.SendMail() wait window loSmtp.cErrorMsg RETURN ENDIF
In addition to the error message you can also log the entire SMTP conversation with the server assuming you managed to connect in the first place. To see the session set the .cLogFileProperty to a filename that will act as your log file:
loSmtp.cLogFile = FULLPATH("SmtpLog.txt") llResult = loSmtp.SendMail()
The log might give further clues to why an SMTP session failed on the server.
Last Updated: 1/25/2007 |
Send topic feedback