VBScript Class to Send Mail With CDOSYS

johna by | February 16, 2008 | Classic ASP Web Development

This is my first attempt at a VBScript class.

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

Related Posts

Web Development Retro Computing

Converting dBase IV programs to run in the browser

by johna | September 13, 2024
Some pointless entertainment trying to get some old dBase programs running in the browser.

Web Development

How to set up a debugging using the Turnkey Linux LAMP stack and VS Code

by johna | December 19, 2023
The second part in my guide to setting up a website and database using the Turnkey Linux LAMP stack.

Website Hosting Web Development

How to set up a website and database using the Turnkey Linux LAMP stack

by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).

Comments

There are no comments yet. Be the first to leave a comment!

Leave a Comment

About

...random postings about web development and programming, Internet, computers and electronics topics.

I recommend ASPnix for web hosting and Crazy Domains for domain registration.

Subscribe

Get the latest posts delivered to your inbox.