Tuesday, 29 November 2011

CDONTS

One of the most common ways to send form data is with the CDONTS email component. In this script, we will use CDONTS to send data from a basic text box and a textarea box.

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

Email:
First Name:
Last Name:
Subject:
Comments:


Next, we create a confirmation.asp page with our CDONTS code as seen below:

<% DIM strEmail, strName, strComments, mail, reply, objMail strEmail = request.form("Email") strName = request.form("Name") strComments = request.form("Comments") mail = "YOUR EMAIL ADDRESS HERE" reply = request.form("Email") Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = reply objMail.Subject = "YOUR SUBJECT MESSAGE HERE" objMail.To = mail objMail.Body = "Email: " & strEmail & vbCrLf & _ "Name: " & strName & vbCrLf & _ "Comments: " & vbCrLf & strComments objMail.Send Set objMail = nothing %>

<% strName = request.form("Name") Response.Write strName %>,


Thank you for emailing me.


Now you have a complete form that sends data to an email address and displays a customized message for your user. The default format for CDONTS is to send plain text messages. If you want to send HTML messages with CDONTS, you can simply include these two extra lines of code before the objMail.Body line.

objMail.BodyFormat=0
objMail.MailFormat=0

Enjoy!
http://www.aspwebpro.com/aspscripts/email/cdonts.asp

No comments:

Post a Comment