Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Asp Email Made Easy Using Cdo

Rated 3.91 (Ratings: 1)

Want more?

  • More articles in Code
 

Burhan Khalid

Member info

User since: 08 Aug 2001

Articles written: 3

Before you write one lick of code, think about these things :

Just because people have email accounts, that doesn't mean that you should have free reign and send them all sorts of nonsense. If you are going to ask for their email address, do not abuse it. Its akin to asking someone for their telephone number, or home address. What if everytime you told someone your phone number, you got calls from people you didn't know trying to tell you how they can get you a college diploma for $25? Not only that, you get these phone calls up to 80 times a day? I understand that some people have websites up there that are running on whats called click-thru or reference dollars. If you have such a partnership, please have the decency to add a little footer telling people on how to opt out. And I don't mean that little footnote written in font size -1000 that would take a guy with a 32 inch plasma screen four microscopes to read. Well, enough about that. I trust we are all sensible netizens. You guys know what I'm talking about.

Now, on to the good stuff: how do I send mail from my webpage? If you are on any Microsoft platform, and you are scratching your head looking for a way to send email via ASP, let me introduce you to your new best friend.

drumroll....

Collaboration Data Objects or CDO for short

What is CDO?

Simply put, CDO is a framework, a bridge if you will, that allows access to an email server. Using CDO, you can create and send messages using the SMTP (IIS 4.0) or through MAPI (MS Exchange Server) more on this later. But first, three lines of code to send email!

<%

Set mailHook = Server.CreateObject("CDONTS.Newmail")

mailHook.Send "you@you.com","joe@target.com","Subject","Body"

Set mailHook = nothing

%>

That's it! --Instant email sending. But I know what you are thinking, "what the heck is CDONTS? He was just talking about CDO earlier." Fear not, read on.

Two Versions of CDO

There are two versions of CDO available from Microsoft. CDO 1.2 and CDO for NTS (NT Server). CDONTS is a trimmed down version of CDO 1.2 and is included with IIS 4 and 5. CDO 1.2 is the full blown version, and it is bundled with Microsoft Exchange Server. I believe that Microsoft has come out with newer versions of CDO for the 2K line of products, providing more functionality (or so they say), but more than likely, more bugs. So, I'd stick with 1.2 for now...till the first few rounds of Service Packs are out at least. What is the difference between the two? Nothing too serious on the outside, but the main way they differ is in their communication protocols. CDO uses the Microsoft Messaging Application Program Interface (MAPI) and CDONTS uses Simple Mail Transfer Protocol (SMTP). Below is a simple table of features that are supported on each.

Table of Comparison

FeatureCDO1.2CDONTS
Protocol UsedMAPISMTP
Accessible with ASP?YesYes
NewMail Object?NoYes
Requires authenticated user login?YesNo
Supports remote access?YesNo
Supports multiple servers?YesNo
Provides calendars, filters, sorting?YesNo
Provides for writing to Message Object?YesYes
Provides for reading from Message Object?YesNo
Renders messages in HTML for browser veiwing?YesNo
Uses HTML/MHTML for transmission of rich text and graphics?NoYes

Conclusion

What was the point of all this you may ask? Well, simply put, ASP provides for easy integration of email capabilities into existing solutions through the use of Collaboration Data Objects. Think of it this way: you compile an ActiveX DLL that stores all your emailing code, with of course code that will filter, sort, etc. your mailing lists, and you have a powerful and fast (compiled DLLs are always faster than inline ASP) way of implementing email. So, the next time a user hobbles on to your site, you can provide customized content, interesting emails (err...), flyers that have your site updates included (hmm...), your schedule and when you are free (*scratches head*)...wait, why did I write this?! This is the perfect weapon for all those that want to mailbomb people! Come to think of it...maybe I should delete this thing...ah heck, I'll just send an email to have it done ;)

On a personal note, I was wondering if anyone had any ideas on how to implement a similar solution ... using PHP? [This would make a great followup article --ed]

As always, I look forward to your replies, complaints, etc.

I'm a college student finishing up my Bachelor of Science degree at Southwestern Oklahoma State University. I generally try to help out at evolt, answering questions on the list, and occasionally writing an article or two. I am the current president of the computer club, the only computer science tutor, and the webmaster for our site. In addition to traveling around the world (I speak 5 languages), in my free time I like to fly (both sims and real aircraft), read, and play around on the internet.

That was 8 years ago - now I'm a IT consultant, e-commerce and Linux SME in Kuwait. I currently work for a large engineering consultancy firm where I am responsible for IT strategy for the company and consulting with client on their large-scale IT projects.

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.org Evolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.