Sending SSL Email with wwSmtp (GMail, Live, etc.)

The following example demonstrates sending an email with attachments via GMail.

In order to send TLS/SSL Emails you have to use the .NET mode of wwSmtp. To do this make sure you set loSmtp.nMailMode=0.

Note that this should also work with other providers like or any provider that requires SSL based SMTP connections.

DO wwSmtp 

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

loSmtp.nMailMode = 0  && .NET Mode required

*** Google SMTP server - requires login and SSL/TLS
loSmtp.cMailServer = ""

*** Important for Secure SSL/TLS connections
loSmtp.lUseSsl = .T.

loSmtp.cUsername = ""  && or whatever uid is
loSmtp.cPassword = "yourpassword"

loSmtp.cSenderName= "wwIPstuff Samples"
loSmtp.cSenderEmail = ""

loSmtp.cRecipient = ["Jimmy" <>]

*** Actual message properties
loSmtp.cSubject = "wwSMTP Test Message"
loSmtp.cMessage = "<b>HTML Test message from wwsmtp, to check out how this operation works.</b>"

*** If cMessage contains HTML set cContentType to text/html
loSmtp.cContentType = "text/html"

*** Optional To add attachments use Attachment and point at a full file path

llResult = loSmtp.Sendmail()
IF llResult
    WAIT WINDOW "Mail sent..." nowait
    ? "Mail sending failed: " 
    ? loSmtp.cErrorMsg

© West Wind Technologies, 1996-2019 • Updated: 09/21/17
Comment or report problem with topic