spacer
Web Development Tutorials ASP Tutorials
 Developer Newsletter

Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous


Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET
Budget
Dedicated Servers
Ecommerce
Linux
Resellers
Shared
Small Business
Windows

Developer Manuals
Learn HTML
Learn PHP
Learn CSS
Learn AJAX
Learn JavaScript
Learn Pear
Free White Papers

Developer Resources
Developer Tools
Developer Content
Survey Software
Dedicated Servers




Sending HTML Email with ASP

By Amrit Hallan
2005-06-01


Sending HTML Email with ASP

Last time you learnt how to receive or send form data using ASP. Let's now see how we can send HTML messages using the Active Server Pages. The process is quite similar to sending the regular, text message, but yes, there are a few modifications. Using the code given below, you can send HTML messages:

== Code Begins ==

<%

Dim htmlMess ' THIS STORES THE HTML CODE
' PLEASE TAKE CARE ABOUT YOUR DOUBLE QUOTES

htmlMess = "<html><head><title>HTML message in Email</title>"

htmlMess = htmlMess & "<style>"

htmlMess = htmlMess & "h1{font-family : Arial; font-size : 16pt; font-weight : bold; color: #000000;}"

htmlMess = htmlMess & "p{font-family : Arial; font-size : 10pt; color: black; text-align : justify;}</style></head>"

htmlMess = htmlMess & "<body bgcolor='#ffffff'>"

htmlMess = htmlMess & "<h1>My HTML Message from an ASP Page!</h>"

htmlMess = htmlMess = & "<p>This message has been written in HTML format.</p></body></html>"

' FIRST I'LL SHOW HOW TO DO IT IN CDONTS, AND THEN IN SMTP

Dim oSendMailer

' CDONTS BEGINS

Set oSendMailer = Server.CreateObject("CDONTS.NewMail")

oSendMailer.To = "ToEmail"
oSendMailer.From = "FromEmail"
oSendMailer.Subject = "Subject Matter"

' THE FOLLOWING ARE THE EXTRA SETTINGS:
oSendMailer.BodyFormat = 0
oSendMailer.MailFormat = 0

oSendMailer.Body=htmlMess

oSendMailer.Send

set oSendMailer = nothing

' CDONTS ENDS

' SMTP BEGINS

Set oSendMailer = Server.CreateObject("SMTPsvg.Mailer")

oSendMailer.FromAddress = "FromAddress"

oSendMailer.FromName = "FromName"

oSendMailer.AddRecipient "Recipient Name", "RecipientEmail"

oSendMailer.RemoteHost = "mail.yourdomain.com"

oSendMailer.Subject = "Subject Matter"

oSendMailer.ContentType="Text/HTML"

oSendMailer.BodyText = htmlMess

oSendMailer.SendMail

set oSendMailer = nothing

' SMTP ENDS

%>

== Code Ends==



Tutorial Pages:
» Sending HTML Email with ASP


 | Bookmark Print |   Write For Us
Related Tutorials:
» Decision Making and Looping
» Arrays in ASP
» Emailing Form Data with ASP
» Dumping Form Information Onto a Web Page
» Installing Personal Web Server
» Your First ASP Page



About the NetVisits, Inc Network | Write For Us | Advertise
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: