Since Windows XP, Microsoft is not including CDONTS on its operating systems. Instead it uses the new and more powerful mail component CDOSYS that was already present in Windows 2000.
It is still fairly simple to send a simple email although some more advanced functions are a bit more complex. We will show you how to send a simple email and how to add additional advanced configuration parameters.
The Object (CDO.Message) has several properties and methods that you must know:
.From E-mail address of the sender
.To E-mail address of the recipient
.CC E-mail address of the CC recipient
.Subject Subject of the message
.TextBody Body of the message in plain text
.HTMLBody Body of the message in HTML
.Send Calling this method the message is sent
The following example is the simplest email you can send.
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "127.0.0.1"
.Item(sch & "smtpserverport") = 25
'.Item(sch & "smtpauthenticate") = 1 'basic (clear-text) authentication
'.Item(sch & "sendusername") ="firstname.lastname@example.org"
'.Item(sch & "sendpassword") ="yourpassword"
Set cdoMessage = CreateObject("CDO.Message")
Set .Configuration = cdoConfig
.From = "email@example.com"
.To = "firstname.lastname@example.org"
.Subject = "Test CDOSYS"
'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
.HTMLBody = "email message goes here"
Set cdoMessage = Nothing
Set cdoConfig = Nothing