Blog Tools
Edit My Blog
RSS Feed RSS
About Me
Contact Me

< < Feb 2008 > >
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29  
You are not signed in.
Sign in

Entries By Topic
·All Topics RSS
·Classic ASP RSS
·CSS RSS
·Databases RSS
·eBay/PayPal RSS
·General RSS
·Hardware RSS
·Web Security RSS
·Windows XP RSS

Search
 
Recent Entries
·eBay encourage/force you to lose money on postage
·CAPCTHAs and alternatives
·Obtaining Image Properties in ASP Without a Component
·New Microsoft Hotmail good reason not to use Microsoft Explorer
·Why are most real estate agents so bad at selling online
·Classic ASP Title Case
·Does stopfax.com.au really stop junk faxes?
·SQL Injection Protection - b.js
·Unfair eBay fees for used cars
·100% CSS Layout

John's Blog

VBScript Class to Send Mail With CDOSYS

Posted at: February 16, 2008
Related Topic(s): Classic ASP

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


View Comments (0) | Add Comment | Permalink

Newer | Latest | Older

Free automotive classifieds, reviews, etc

Car and motorcycle books and repair manuals

ASP Hosting and Domain Names

For cheap asp and asp.net hosting I recommend CrystalTech, for cheap .com domains Cheeky Domains, or for .com.au domains Name Scout.

[Oztion is an Australian auction website which offers no listing fees]