Home | About Us | FAQ
    Products
Development
 
AZ Office:
voice (602) 750-6161
Send an e-Mail
 
   
 

How to Send Email using CDONTS from Active Server Pages (ASP)


Comsoltech® Incorporated

Summary
This article and ASP script shows how to send email in ASP page, using CDONTS component which comes with Microsoft IIS server in an easy and simple way.

Applies To
Active Server Pages (.ASP) envinronment using Windows NT Server, 2000 Server running IIS 4.0, 5.0 or beyond.

Contents

There are several ways you can send email from your ASP environment. The simplest, and affordable way is to use Microsoft's own CDONTS mail component that comes with Microsoft IIS 4.0 or better.

If your web site is hosted by some other companies that you don't have access to the server directly, and they do not have CDONTS component installed, then ask your ISP whether they can install this component.

For article on how to send email using third party email component (using JMail component), go to this article.

here's the HTML file that contains initial form, and ASP script that sends the actual email. (No error checking for simplicity.)

mailform.htm

<html>
<form method=post action=sendmail.asp>
From email: <input type=text name=sender><br>
To email: <input type=text name=receiver><br>

Subject: <input type=text name=subject><br>
Body: <textarea name=body></textarea><br>
<input type=submit>
</form>
</html>


sendmail.asp
set mail=server.CreateObject("CDONTS.NewMail")
mail.From= Request("sender") ' like my.email.addr@comsoltech.com
mail.To = Request("receiver") ' like john.doe@comsoltech.com
mail.Subject = Request("subject")
mail.Body = Request("body")
mail.BodyFormat = 0 ' 0 = HTML, 1 = Plain
mail.MailFormat = 1 ' 0 = MIME, 1 = Text
mail.Importance = 1 ' 0 =High, 1 = Medium, 2 = Low
mail.attachFile ("c:\images\mypicture.gif")
' you can also attach files
mail.Send
set mail=nothing


Good luck, and happy programming!
Comsoltech® Inc
http://www.comsoltech.com


(C) 1998 - 2010 Comsoltech® Incorporated. All Rights Reserved. info@comsoltech.com
Comsoltech is a registered trademark of Comsoltech Incorporated.
Home | Products | Development
4Templates.com   | Save on QuickBooks Products + Free Shipping