Inbox and Outbox Manipulation in ASP (Page 1 of 4 )
Have you ever wanted to use Active Server Pages for sending and receiving email? Burhan Khan explains how to use CDO to set this up.There are numerous ways to send and receive emails using ASP. The simplest way is to use CDO. CDO is a free emailing component which comes packaged with NT Option Pack 4. If you want to receive email, you can use the CDO session object. This article will explain ways to sending and receive email through ASP 3.0. After you finish reading it, you will be able to design a simple Web page for sending and receiving email.
Sending Emails Using CDO: Outbox
Sending email through Active Server Pages is not a difficult task. There are too many ASP components that are used to send email using ASP. One method growing in popularity is the Collaborative Data Object (CDO). One reason for its popularity is that it is a fast and free method of sending email. Another reason is that it ships with NT Option Pack 4 by default, so you don’t need to buy and install it.
To start sending email, the first step is to create an instance of a CDO object in your ASP code. It is as simple as:
<%
dim objMail
set objMail = Server.CreateObject("CDONTS.NewMail")
%>
CDONTS.NewMail has easy to use properties and methods. These include ".TO," ".From," ".CC," ".BCC," ".Subject," and ".Body." Let's look at some code:
<%
objMail.To = "burhansk@hotmail.com"
objMail.From = "user@yahoo.com"
objMail.cc = "me@mydomain.com"
objMail.bcc = "me_bcc@mydomain.com"
objMail.Subject = "This is subject line"
objMail.Body = "Here is body of email"
objMail.Send
%>
In the above code, I initialize CDO properties, and use .Send to send email. One wonderful thing about CDO is that, if you use an incorrect email address in properties, CDO will never send through any error, but it also will not send email. So correct email addresses are compulsory.
CDO also has too many features, like file attachment, priority, HTML body, and so forth. I am not going to explain these features of CDO because too many articles have already been written on this issues. Let's explore some other issues.
Next: CDO is not everything >>
More ASP Code Articles
More By Burhan Khan