It allows full control of the CDO Message object.
You can create a new instance of the class with the following:
Dim clsSendMail Set clsSendMail = New SendMail
Then add the various properties of the email:
clsSendMail.SendTo = "email@example.com" clsSendMail.From = "firstname.lastname@example.org" clsSendMail.Subject = "Test Message"
Next you choose what type of mail you are going to send: plain text, HTML or from a URL or local file.
|Plain Text||TextBody||clsSendMail.TextBody = "message here"|
|HTML||HTMLBody||clsSendMail.HTMLBody = "<b>html</b> message here"|
|URL||CreateMHTMLBody||Call clsSendMail.CreateMHTMLBody "http://www.url.com/pagename.htm"|
|Local File||CreateMHTMLBody||Call clsSendMail.CreateMHTMLBody "file://c:/mydocuments/test.htm"|
To add an attachment use the following:
Call clsSendMail.AddAttachment "c:\mydocuments\test.txt"
To embed files in your message use:
clsSendMail.AddRelatedBodyPart "/older/imagefile.gif", "image1.gif"
This can then be included in your HTMLBody by referencing the second parameter as the CID, for example:
You can also set a SMTP server and port if neccessary:
Call clsSendMail.SMTPServer "mail.test.com", 25
by John Avis | February 20, 2019
I was recently doing some work on a website which has a mixture of older Classic ASP pages and ASP.NET Web Forms pages and ran into problems with custom error pages.
by John Avis | March 21, 2017
I recently needed to change a client's website to send emails using Amazon SES and encountered a few issues.
by John Avis | June 8, 2016
Although probably no one cares about Classic ASP, except those who still need to support it, I was refreshing my memory today on how to use classes in Classic ASP and found a couple of options for simulating constructors with parameters.