CDOSYS is a built-in component in ASP used to send e-mails.  CDOSYS was designed to replace Microsoft’s older CDONTS component, which was phased out in Windows 2003.

The first thing you need to do is create a /FormPage.asp page with the code below:

<form name="YourFormName" method="Post" action="confirmation.asp">
Email:  <input type="text" name="Email" size="50"><br>
First Name:  <input type="text" name="FirstName" size="50"><br>
Last Name:  <input type="text" name="LastName" size="50"><br>
Subject:  <input type="text" name="Subject" size="50"></td><br>
Comments:  <textarea name="Comments"></textarea><br>
<input type="submit" name="Submit" value="Submit Form">


Next, we create a /Confirmation.asp page with our CDOSYS code as seen below:

DIM strEmail, strFirstName, strLastName, strComments
strEmail = request.form("Email")
strFirstName = request.form("FirstName")
strLastName = request.form("LastName")
strComments = request.form("Comments")

Set myMail=CreateObject("CDO.Message")
myMail.Configuration.Fields.Item _
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
'SMTP Username and Password
myMail.Configuration.Fields.Item _
("") = "YourUsername"
myMail.Configuration.Fields.Item _
("") = "YourPassword"
myMail.Configuration.Fields.Item _
("") = 1

myMail.From = strEmail
myMail.To = ""
myMail.Bcc = ""
myMail.Cc = ""
myMail.Subject = "CDOSYS Email"
myMail.TextBody = strComments

'Catch any errors.
On Error Resume Next
If (Err <> 0) Then
Response.Write "There was an error sending the email: " & Err.Description
End If

Set myMail = nothing

strFirstName = Request.Form("FirstName")
Response.Write strFirstName

<p>Thank you for emailing me.</p>


Now you have a form that sends a text email and displays a customized message for your user. If you would like to send an email in HTML format, you can simply replace “myMail.TextBody” with “myMail.HTMLBody.


< Back to ASP Scripts