Send Email | email Introduction
CDONTS is actually replaced by CDOs already in Windows XP. But these operating Systems supported CDONTS, and your could use CDONTS. Windows Server 2003 does not support CDONTS, and we are forced to use CDO. This tutorial is a crash course in CDO, and we would create a few simple Web forms for sending emails with CDO and ASP.
Before we begin
Before I show you the any code, there are a few things we must does to the to work. The thing is set up a Web Server–iis 6.0. You can start the wizard for the installation of IIS 6.0 from Manage Your Server (start->programs->administrative to Ols->manage Your Server).
Click Add or remove a role.
Select Application Server
You don't need asp.net nor FrontPage Server Extensions for this tutorial
But that isn't enough; We also need the SMTP server to send our emails, though I'll also show your how to use a remote server instead of the LOC Al. So, open up Add or Remove Programs to the control Panel.
Click Add/remove Windows Applications
Highlight application Server, and click Details
Highlight Internet Information Services (IIS) and click Details
Select SMTP Service and click OK, and finally Next
We are almost ready for the "code writing now, but since IIS 6.0 are locked down by default, we have to the the Internet I nformation Services Manager (start->program->administrative Tools) and enable the ASP extension.
When the IIS Manager is has started, click on the Web Service Extensions into the left pane.
Select Active Server Pages, and click on Allow
That ' s it! We are now ready to the fun part, the coding!
A Simple Text Email
So, start your favorite text editor, and type this:
01|<%
02| If Request.Form ("Btnsend"). Count > 0 Then
03|
04| Set objmessage = CreateObject ("CDO.") Message ")
05| Objmessage.subject = Request.Form ("Subject")
06| Objmessage.sender = Request.Form ("from")
07| Objmessage.to = Request.Form ("to")
08| Objmessage.textbody = Request.Form ("message")
09| Objmessage.send
10| Response.Redirect ("sent.html")
11| End If
12|%>
13|
14|15| 16| <title>send Email with cdo</title>
17| 18| <body>
19| <form name= "SendEmail" action= "emailwithcdo.asp" method= "POST" >
20| <table>
21| <tr>
22| <td>Subject:</td>
23| <td><input type= "text" name= "subject"/></td>
24| </tr>
25| <tr>
26| <td>From:</td>
27| <td><input type= "text" Name= "from"/></td>
28| </tr>
29| <tr>
30| <td>to: </td>
31| <td><input type= "text" Name= "to"/></td>
32| </tr>
33| <tr>
34| <TD valign= "Top" >message: </td>
35| <td><textarea name= "Message" rows= "6" cols= ">"
36|</textarea></td>
37| </tr>
38| <tr>
39| <TD colspan= "2" ><input type= "Submit" Name= "Btnsend"
40|value= "Send"/></td>
41| </