wwSMTP::SendMessage

Sends a single message to an SMTP server, but allows multiple messages to be sent on a single open SMTP connection. Requires that you call Connect() before SendMessage() calls and Close() or Dispose() after.

Unlike SendMail this operation is meant for multiple messages to be sent where a connection is opened and then multiple messages are sent, then the connection is closed:

loSmtp.Connect()

*** Send many messages to different addresses
SCAN 
   ? loSmtp.SendMessage( TRIM(Email) )
   ? loSmtp.cErrorMsg
ENDSCAN

loSmtp.Close()

Note that unlike SendMail() this method accepts the Recipient, CC and BCC values as input parameters since these might be changing for each message sent. All remaining properties are the same.

o.SendMessage(lcRecipient, lcCC, lcBcc)

Parameters

lcRecipient
The comma delimited list of main recipients of this message

lcCC
Optional - A comma delimited lists of email addresses that show as CCs.

lcBcc
Optional - A comma delimited lists of email addresses that show as CCs.

Example

DO wwSmtp 
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

*loSmtp.cMailServer = "Localhost"
loSmtp.cMailServer = "smtp.gmail.com:587"
loSmtp.lUseSsl = .T. && Google requires TLS

*** Optional authentication if server requires it
loSmtp.cUsername = "ricks"
loSmtp.cPassword = "secret"

loSmtp.cSenderName= "West Wind Tools"
loSmtp.cSenderEmail = "admin@test.com"

loSmtp.cRecipient = "ricks22@hotmail.com,admin@mydomain.com"
loSmtp.cCcList = "admin2@mydomain.com,admin@monitor.com"

*** Optional - custom content type - text/plain by default
loSmtp.cContentType = "text/html"

loSmtp.cSubject = "Test Message through Google"
loSmtp.cMessage = "<b>Test message from wwsmtp, to check out how this operation works.</b>"

*** Optionally attach files
loSmtp.cAttachment = "c:\rick4453.jpg,c:\sailbig.jpg"

*** Optional - a couple of options
loSmtp.cReplyTo = "james@cranky.com"
loSmtp.cPriority = "High"

loSmtp.Connect()

*** Send many messages to different addresses
SCAN 
   ? loSmtp.SendMessage( TRIM(Email) )
   ? loSmtp.cErrorMsg
ENDSCAN

loSmtp.Close()

See also:

Class wwSMTP | wwSMTP::SendMail

© West Wind Technologies, 1996-2018 • Updated: 11/29/16
Comment or report problem with topic