When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs



















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Senior Software Developer
Professional Technical Resources
US-CA-Santa Clara

Justtechjobs.com Post A Job | Post A Resume

Sending HTML-Formatted Email
By Rob Taylor


You can send email messages in HTML format with the SMTP service (CDONTS) or MS Exchange. However beware that not all mail clients will display it properly.

By default, CDONTS sends its emails in plain-text format. With HTML-formatted email, however, we can do all sorts of neat stuff, such as having different fonts, italics, colored text, embedded-images, etc.

<%
  Dim objMail
  Set objMail = Server.CreateObject("CDONTS.NewMail")
   
  '//these are all the images that are in this message.
  '//you must include them like this.
  '//please note that you DO NOT have TO write the
  '//entire file path in the <IMG> tag in the body after this.
  '//make sure you see the image name after the path separated by a comma
   
  objMail.AttachURL "D:\images\myImage.gif", "myImage.gif" 
  objMail.AttachURL "D:\images\myImage2.gif", "myImage2.gif" 

 
  HTML = HTML & "<HTML>"
  HTML = HTML & "<HEAD>"
  HTML = HTML & "<TITLE>Send Mail with HTML</TITLE>"
  HTML = HTML & "</HEAD>"
  HTML = HTML & "<BODY  bgcolor=""lightyellow"">"
  HTML = HTML & "<TABLE cellpadding=""4"">"
  HTML = HTML & "<TR><TH><FONT color=""darkblue""  SIZE=""4"">"
  HTML = HTML & now() & " - "
  HTML = HTML & "These are all great ASP Sites</FONT></TH></TR>" 
  HTML = HTML & "<TR><TD>"
  HTML = HTML & "<A HREF=""http://www.4guysfromrolla.com"">"
  HTML = HTML & "<IMG SRC=""myImage.gif""></A><BR><BR>"
  HTML = HTML & "<A HREF=""http://www.4guysfromrolla.com"">"
  HTML = HTML & "<IMG SRC=""myImage2.gif""></A><BR><BR>"
  HTML = HTML & "</FONT></TD></TR></TABLE><BR><BR>"
  HTML = HTML & "</BODY>"
  HTML = HTML & "</HTML>"
  
  objMail.From = "rob@tconsult.com"
  objMail.Subject = "Your daily HTML Mail"
      
  'you need TO add these lines FOR the mail
  'to be sent in HTML format
  objMail.BodyFormat = 0 
  objMail.MailFormat = 0 

  objMail.To = "you@yourhouse.com
  objMail.Body = HTML
  objMail.Send
  
  Response.write("Mail was Sent")
  set objMail = nothing
%>

FAQ Table of Contents   Displaying Line Breaks in an Email  


Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers