Articles   Dev Forums   Personalize   Favorites   Member Login   ASP Hosting      Active Users:  89
DevASP - ASP and XML Articles, Samples, Toturials, Sample Chapters and resources for Developers Friday, May 09, 2008
Home
Articles & Samples
ASP Hosting
Dev Search
Dev Forum
Add Your Articles
Add a Listing
Sample Chapters
Directory Feed
Link to US
Contact

Search Directory
Applications
Articles & Samples
Components
Community
Database
Developer Sites
Downloads
Hosting Services
Introduction
Knowledge Base
Sample Chapters
WebCasts

ESET
ASP Directory
Applications
Articles & Samples
Components
Developer Sites
Knowledge Base
Sample Chapters
WebCasts
XML Directory
Applications
Articles & Samples
Developer Sites
Error, Bugs & Fixes
Downloads
Introduction
Knowledge Base
Sample Chapters
WebCasts


Sending Email in HTML format using CDONTS.NewMail Object

This Sample code will help you understand how you can send a HTML formated email from an ASP page using the CDONTS.NewMail object.




<%
Option Explicit

Dim objMail
Dim strSubject
Dim strBody

strSubject = "This is a test email in HTML format"

strBody = "<HTML>" & _
     "<HEAD></HEAD>" & _
     "<BODY>" & _
     " <Font Face=Arial Size=5><B>" & _
     "  This is a test Email" & _
     " </B></Font><BR>" & _
     " <H3><A Href=http://www.devasp.com>Click here</a>" & _
     " to go to DevASP.com</h3>" & _
     "</BODY>" & _
     "</HTML>"

' First create an instance of the NewMail Object
Set objMail = Server.CreateObject("CDONTS.NewMail")

' Please replace the "From" and "To" email addresses with your
' own valid email address. I recieve too many emails
' from people who test this sample and keep sending
' emails to test@devasp.com, or they keep the "From" property
' as webmaster@devasp.com and I get response of
' undeliverable emails.
' NOTE: If the "To" or "From" properties of CDONTS contain
' invalid email address you will not recieve the email.

objMail.From    = "test@devasp.com"
objMail.To      = "someone@devasp.com"
objMail.Subject = strSubject
objMail.Body    = strBody

' In order to send the email in HTML format we have to set
' both MailFormat and BodyFormat equal to zero

objMail.MailFormat = 0
objMail.BodyFormat = 0

objMail.Send

Set objMail = Nothing
%>

Have Questions? Discuss this topic in Dev Forum

Related Articles

   Sending Mail with CDONTS.NewMail Object

   Setting the Reply-To Header in an Email using CDONTS.NewMail Object

DevASP - Privacy - Disclaimer
Copyright © 2008 DevASP.com