This JustCode script shows us how to send an HTML email using the CDO object. This is good for error logging systems , when the survey errors it sends you a message , that way you dont have to keep looking in the log files.
' **************************************** ' Designed by : Smarter Dimensions ' Last Updated : 7th July 2009 ' **************************************** ' Email objects Dim oEmail, sEmailFrom, sEmailTo, sEmailSubject, sEmailBody,sBCC ' Send email sEmailTo = "admin@SmarterDimensions.com" sEmailFrom = "FromAddress@SmarterDimensions.com" sEmailSubject = "Email Subject" sEmailBody = "Email Body this is bold" sBCC = "SmarterDimensions@live.com.au" Set oEmail = CreateObject("CDO.Message") With oEmail With .Configuration.Fields .Item["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "[SERVERNAME]" .Item["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2 .Item["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "[USERNAME]" .Item["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "[PASSWORD]" .Item["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 587 .Item["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1 .Update() End With End With oEmail.From = sEmailFrom oEmail.To = sEmailTo oEmail.BCC = sBCC oEmail.Subject = sEmailSubject oEmail.HTMLBody = sEmailBody oEmail.Send() set oEmail = Null
Hey guys,
Here is an example with “Outlook.application”:
Dim mOutlookApp,objMail
Set mOutlookApp = CreateObject(“Outlook.application”)
Set objMail = mOutlookApp.CreateItem(0)
objMail.Display()
objMail.to = “xxx@yyyy.com ”
objMail.cc = “”
objMail.Subject = “Test”
objMail.Body = “Test”
objMail.Send()
Set objMail = NULL
Set mOutlookApp = NULL