« Firefox-Restoring bookmark backups | Home | why you should care about Web standards »
HTML Email with ASP
By bob | March 12, 2008
Here is the way you can send HTML email by using the Active Server Pages using the following code.
<%
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
%>
Topics: web development |
