VBScript Class to Send Mail With CDOSYS
by johna | February 16, 2008 | Classic ASP Web Development
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 = "test@test.com" clsSendMail.From = "test@test.com" 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.
Type | Property/Method | Syntax |
---|---|---|
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:
<img src="cid:image1.gif">
You can also set a SMTP server and port if neccessary:
Call clsSendMail.SMTPServer "mail.test.com", 25
SendMail Class
Comments
There are no comments yet. Be the first to leave a comment!