Important alert: (current site time 7/16/2013 12:02:01 AM EDT)
 

article

Sending an HTML Email with ASP

Email
Submitted on: 6/14/2000 5:51:43 PM
By: Brad Humphrey  
Level: Intermediate
User Rating: By 13 Users
Compatibility: ASP (Active Server Pages)
Views: 57525
(About the author)
 
     Have you ever wondered how to send an HTML email in ASP?...I have...and when I couldn't find it here on Planet Source Code when I was stuck I figured it was my turn to return the favour to the site!! This code will send nicely formated HTML emails

This article has accompanying files
 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				To send an HTML file in ASP you simply have to add a few more lines to what would be a regular email message!

winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/15/2000 8:37:51 AMMagnus Simonarson

Works great....I've been looking for this for ages...Thanks!
(If this comment was disrespectful, please report it.)

 
6/19/2000 4:21:56 PMJamie Daniel

How can I add pictures and backgrounds to the html email. I tried using HTML tags to do it but I have had no luck.
(If this comment was disrespectful, please report it.)

 
6/19/2000 10:42:40 PMBrad Humphrey

Put the images on a server somewhere and route the pics and backgrounds to those images on that server. Most likely the persom getting that email is still going to be on the internet when he/she reads that email and therefore the email will grab those images off of the server.
(If this comment was disrespectful, please report it.)

 
6/19/2000 11:00:25 PMadam

Where do you get the CDONTS file at? I keep getting this error:
(If this comment was disrespectful, please report it.)

 
6/21/2000 5:19:50 AMKrede

Your server has to support CDONTS. You have to install the SMTP components in Service Pack 4 on a NT server. Good luck
(If this comment was disrespectful, please report it.)

 
7/27/2000 1:21:16 PMjim

do you know how to format the text in an email. i have tried using html tags, but that doesn't seem to work. can you advis anything?
(If this comment was disrespectful, please report it.)

 
10/11/2000 9:21:03 PMVisualBlind

what do you mean by objMail?
(If this comment was disrespectful, please report it.)

 
10/11/2000 9:24:23 PMVisualBlind

Where can I get that CDONTS.newmail object, i get an error...
(If this comment was disrespectful, please report it.)

 
2/19/2001 8:44:35 AMVinkie

Is it possible to include variables passed from a form. I have a submit page that is sending 3 varialbe, location, name and email. when I tried to use insert Request.Form(name) it choked. I also tried: objCDO.Body =
(If this comment was disrespectful, please report it.)

 
3/7/2001 10:38:03 PMbench

won't this code run in Win98 OS?...i got an ActiveX Component error.
(If this comment was disrespectful, please report it.)

 
4/23/2001 1:31:30 PMReply to vinkie:

make your 3 form results all variables..
name = request.form(
(If this comment was disrespectful, please report it.)

 
4/23/2001 1:31:59 PMReply to vinkie:

make your 3 form results all variables..
name = request.form("name") etc and the in the body part put:
"Thank you " & name &" @ " & email & ", from " & location
-
There, thats how to add form results to an e-mail, hope that helped :)
(If this comment was disrespectful, please report it.)

 
5/24/2001 8:12:10 AMSandeep

I want to get in to email marketing with preferably asp solutions which might be hosted on a hired server space. Kindly suggest step-by-step procedure and requirements. I have simple codes in asp .
(If this comment was disrespectful, please report it.)

 
6/22/2001 4:12:13 AMRob

I couldn't see the background image thru web-based email server such as: Yahoo, Hotmail etc. What should I do to fix this issue. Thanks Rob -- etouring@hotmail.com
(If this comment was disrespectful, please report it.)

 
7/3/2001 11:07:31 AMAlfonso Vega

I want to send html-email from several forms , I need to do it with a button
but , I don't can to do a programm for each form inside body of message. Can you do it? It's possible ?
I tried with
(If this comment was disrespectful, please report it.)

 
11/28/2001 1:56:37 PMRobert Ellis

This will be a great tool. I have one question though. How do you email multiple users at one time? ellisre@1fssg.usmc.mil
(If this comment was disrespectful, please report it.)

 
2/21/2002 5:20:37 PMJim Moss

I am unable to download the article. The zip file contains one txt file.
(If this comment was disrespectful, please report it.)

 
3/14/2002 11:38:16 AMvirtualsailor

jim moss
if the .txt file comes up go to file save as. And to you others which ASP host should i use for this? brinkster doesnt work :(
(If this comment was disrespectful, please report it.)

 
3/28/2002 8:43:46 AMAlirezasaberi

I'm Using a linux server and get CDONT Error
Help me?
(If this comment was disrespectful, please report it.)

 
3/29/2002 4:34:16 AMxxx

xxx
(If this comment was disrespectful, please report it.)

 
1/31/2003 8:33:46 PM

This will be a great tool. I have one question though. How do you email multiple users at one time?
(If this comment was disrespectful, please report it.)

 
2/5/2003 11:21:52 PM

Your code is great but I am having one problem. When I test it the email is only sent the first few times i run it. Any suggestions would be greatly appreciated.
(If this comment was disrespectful, please report it.)

 
3/26/2003 5:15:47 AM

Hi Brad,
I tried to use this code but unfortunatey it didn't work.
I need your help please as i have a very urgent task that should use the same concept.
Thanks for help
(If this comment was disrespectful, please report it.)

 
8/20/2003 12:44:54 PMDavid Sopko

Seems that CDONTS isn't included as part of the WinXP SMTP services:

ActiveX component can't create object: 'CDONTS.Newmail'


(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.