articles:

how to send an email using cdosys

The basic code to send an email using classic ASP:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>


Properties:

myMail.Subject = "a subject line"
myMail.From = "some person ‹someperson@domain.com›"
myMail.To = "another@address.com"
myMail.Cc = "ccanother@address.com"
myMail.Bcc = "Bccanother@address.com"
myMail.ReplyTo = "a.different@address.com"
myMail.TextBody = "The message"
myMail.HTMLBody = "‹h1›The message with formatting‹/h1›"


Another very useful property that tells CDOSYS whether or not to auto-generate a multi-format message by creating a text portion from the HTML part that you have provided. Its default is False.

myMail.AutoGenerateTextBody = true

Methods:

myMail.CreateHTMLBody "http://www.freewindowshosting.co.uk"
OR
myMail.CreateHTMLBody "file://c:/mydocuments/test.htm"

myMail.AddAttachment "c:\mydocuments\test.txt"
myMail.Send

References:
W3 Schools - ASP Sending e-mail with CDOSYS
ASP FREE - Sending Emails Using CDO in WSH
Steve Schofield Weblog- How do display a "Friendly name"

Post a comment

name:
(optional)

email:
(optional)

comment: