CDONTS Tutorial
By: Aaron B. Copyright
AaronOutpost.com
CDONTS stands for
'Collaboration Data Objects for Windows NT Server' The
CDONTS
component is installed when you install IIS on NT4, Windows 2000, & Windows
XP.
Download has 4 working examples of
CDONTS E-mail Form's which you can use.
This tutorial concentrates on the CDONTS
NewMail object uses to format and
then send the e-mail and not the HTML and JavaScript details of collecting the
information. I may write those in the future. For purposes right now, just use
the details and study them. HTML and JavaScript is pretty simple.
IMPORTANT WINDOWS XP WITH IIS 5.1 INFO CDONTS component will run on Windows XP, However Microsoft removed the component from IIS 5.1 on Windows XP, so you
need
a copy of the cdonts.dll and register it on the IIS web server.
To use this component to send e-mail you also need the SMTP Server
(installed by default with IIS 4 & 5), or Microsoft Exchange installed on the
web server.
Creating the Code
This page I am creating below is the
send_email.asp mailing component page as seen in the download.
First we need to dimension some variables to get this show on the road.
In theory what you will want to
create is an HTML page with a form to collect information and then submit it as
seen as default.html in the examples available for
download. So, on your
own send_mail.asp you will want to dimension more variables to hold the
information from the form.
In this case I am only going to
dimension one variable to hold the NewMail
Object
Next we need to create
"CDONTS
NewMail"
object on the server.
Set
cdonts_MailObj = Server.CreateObject("CDONTS.NewMail") |
Now we need to construct the email since we have a
NewMail
object
From property
is required! It allows the recipient know who the email is from.
cdonts_MailObj.From = "SenderE-mail@MyDomain.com" |
Now set the recipients (people receiving the email) using the
To property.
cdonts_MailObj.To
= "Recipient@theirDomain.com" |
Property
Cc holds e-mail addresses you wish to
send Carbon Copies of the e-mail.
You list multiple recipients by separating them with either a comma
(,) or a semicolon (;)
This property can be left out.
cdonts_MailObj.Cc
= "Friend1@theirDomain.com;Friend2@anotherDomain.com" |
The
Bcc property
is the Blind Copies list which is formatted the same as
Cc.
Again you can leave
this property out.
cdonts_MailObj.Bcc
= "BlindCopyRecipient1@theirDomain.com;BlindCopyRecipient2@anotherDomain.com" |
Subject
property, self explanatory
cdonts_MailObj.Subject
= "Message Sent from my CDONTS Page" |
You can also change the formatting of the email
using BodyFormat property. The default is Text.
0 = HTML
1 = Text
If you leave this property out the e-mail will be sent as plain text format.
cdonts_MailObj.BodyFormat
= 0 |
If you set
BodyFormat to HTML then you need to set the
MailFormat
property to MIME.
0 = MIME
1 = Text.
The default is text so you can leave this property
out if you are just sending text emails.
cdonts_MailObj.MailFormat
= 0 |
The
Body property holds the message of the email.
Depending on whether or not you allow HTML and MIME is whether or not you can
use HTML in the body. I have them enabled so I included HTML in my body of the
email displayed below.
If HTML is not turned on, HTML codes will appear as
text.
cdonts_MailObj.Body
= "<h2>Hello</h2><br><b>This
is my e-mail in HTML format</b>" |
Importance property tells the mail messaging system when to schedule delivery
of the e-mail.
0
- Low, sent during times of low system use
1
- Normal, sent at regular delivery times (Default) 2
- High, the system will try to send immediately.
cdonts_MailObj.Importance
= 1 |
Now, lets send it! Using the
Send property.
Finally once the e-mail has been sent we can close the server object releasing
server resources.
'Close the server object Set
cdonts_MailObj = Nothing
%> |
The Finished
Project!
There are other properties of the
CDONTS NewMail
object but those are the most common and useful for most
common use.
<%
Dim
cdonts_MailObj
Set
cdonts_MailObj = Server.CreateObject("CDONTS.NewMail")
cdonts_MailObj.From = "SenderE-mail@MyDomain.com"
cdonts_MailObj.To
= "Recipient@theirDomain.com"
cdonts_MailObj.Cc
= "Friend1@theirDomain.com;Friend2@anotherDomain.com"
cdonts_MailObj.Bcc
= "BlindCopyRecipient1@theirDomain.com;BlindCopyRecipient2@anotherDomain.com"
cdonts_MailObj.Subject
= "Message Sent from my CDONTS Page"
cdonts_MailObj.BodyFormat
= 0
cdonts_MailObj.MailFormat
= 0
cdonts_MailObj.Body
= "<h2>Hello</h2><br><b>This
is my e-mail in HTML format</b>"
cdonts_MailObj.Importance
= 1
cdonts_MailObj.Send
'Close the server object Set
cdonts_MailObj = Nothing
%> |
|