Useful Computer Information - Sending an email using CDONTS
Using CDONTS
Below you will find a very basic script in order to send email messages from your server that is supporting CDONTS. It is set up to be able to send 2 emails almost simultaneously:
'Dimension variables
Dim objCDOMail , objCDOMail2
'Create the e-mail server object that holds the CDONTS NewMail Object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
Set objCDOMail2 = Server.CreateObject("CDONTS.NewMail")
'Who is the email to be sent from?
objCDOMail.From = "myemail@domain.com"
objCDOMail2.From = "myemail2@domain.com"
'Who is the e-mail sent to?
objCDOMail.To = "friend1@domain.com"
objCDOMail2.To = "friend2@domain.com"
'Who are the carbon copies sent to?
objCDOMail.Cc = "myFriend1@theirDomain.com;myFriend2@anotherDomain.com"
objCDOMail2.Cc = "myFriend3@theirDomain.com;myFriend4@anotherDomain.com"
'Who are the blind carbon copies sent to?
objCDOMail.Bcc = "myFriend4@thereDomain.com;myFriend5@anotherDomain.com"
objCDOMail2.Bcc = "myFriend6@thereDomain.com;myFriend7@anotherDomain.com"
'Set the subject of the e-mail
objCDOMail.Subject = "Subject1"
objCDOMail2.Subject = "Subject2"
'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0
objCDOMail2.BodyFormat = 0
'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
objCDOMail2.MailFormat = 0
'Set the main body of the e-mail
objCDOMail.Body = "body1"
objCDOMail2.Body = "body2"
'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 2
objCDOMail2.Importance = 2
'Send the e-mail
objCDOMail.Send
objCDOMail2.Send
'Close the server object
Set objCDOMail = Nothing
Set objCDOMail2 = Nothing
Sign up for our award-winning newsletter: