One of the first things most people try to do with server-side code is send
e-mail. It makes sense. How else can you quickly and easily be notified
when something happens on your web server or someone wants to tell you
something? Well somehow ASP 1.0 shipped without the ability to send e-mail
built into it! (I personally have always wondered what Microsoft was
thinking when they made that decision!) Well because of it, everyone who
needed to send e-mail from ASP wrote their own component. It also quickly
became the most popular type of third-party component. While competition
is great for driving price down (many of them are free) and for the
addition of features (some of them will actually tie your shoes for you),
it makes establishing a standard and sharing code with others a very
When it came for ASP 2.0 to be released, Microsoft caught on. They not
only shipped an SMTP server with IIS4, they gave you a way to use it...CDO.
CDO stands for Collaboration Data Objects. It's a complex name, but for
most of us it simply means we have a way to send mail. Yeah!
[ For those of you who care, it used to be called OLE Messaging, then
Active Messaging, currently it's CDO. It is designed to simplify the
creation of applications with messaging functionality, or to add messaging
functionality to existing applications. Basically we have a way to send
To make this sample at least somewhat interesting, we're actually letting
you send the e-mail. We've tried to remove any reason someone might have
to abuse this by not letting you enter the subject or body, but if it
becomes a problem we'll take it down. Everyone play nice!
If you try this script and can't get it to work, please check to be sure
you have the SMTP server installed and configured on your server and that
you're running it on a computer that's running NT Server 4 & IIS 4.
If you're not running the appropriate setup, want to use a different
mail server possibly on another computer, or just don't like CDONTS for
some reason... you'll need to find a different component. While there
are many good third-party components available to do this, one of ASP
101's partners, Persits Software, has
an excellent component called AspEmail
which is available for free! For more information and a working demo
check out the web site at http://www.aspemail.com.