![]() |
|
|
Published: Sunday, November 22, 1998
Sending email through Active Server Pages is not a difficult task. All you need is love. No, wait; all you need is the Collaborative Data Object, which ships with NT Option Pack 4. To make sure you have it installed, go to Start / Control Panel / Add/Remove Programs / NT Option Pack 4, and see if the SMTP Piece has been installed. If it is *not* installed, you will get an error when you try to run some of the code shown below (the error will read something like, "Invalid class string"). To create an instance of a CDO object in your ASP code, it is as simple as:
Now you're ready to send those emails off! CDONTS.NewMail has a few obvious, easy to use properties and methods. Let's look at some code:
That's all there is to it. The properties are hopefully fairly obvious.
In the above code an email is being sent to mitchelL@4guysfromrolla.com
from gates@microsoft.com, and being CC'ed to barksdale@netscape.com and
jobs@apple.com. The subject is simply the email message. The send method
is what officially dispatches the email (don't forget this, or your email
won't go anywhere!!)
CDO is fairly powerful (and bloated). You can send attachments, send to
group lists, send schedules (like in Outlook).
I also have written an article which was published on 15Seconds.com
dealing with uses of the CDO object. In the article (available through this URL) I discuss
marketing through personalized emailing. The article outlines a good use
for the CDO object.
Let's examine some of the other features of CDO. Below is a snippet of
code which displays some of CDO's extraneous features:
If the file specified by the
As you can see, I've introduced two new properties and a new method. Bcc
is for blind carbon copying. If you send an email "to" someone, and blind
carbon copy someone, the person who receives the email doesn't know that
the message was carbon copied to those on the bcc list. I also used the
Importance property, which takes three values:
The new method introduces is the AttachFile method. This method, as its
name suggests, attaches a file to the email being sent. It takes up to
three parameters, but let's just discuss the first two. The first
parameter is the file you want to attach. In this example I attached
\\server\jane\resume.doc. The second parameter is optional, and it
specifies what you want the name to be in the email message. Here you can
pick some prettier name (like "Jane's Nifty Resume" if you like) than the
full file name. I just named it "Resume.doc".
Happy Programming!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||