Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending e-mails with embedded pictures

Status
Not open for further replies.

AvatarZA

Programmer
Sep 26, 2002
42
0
0
ZA
I am able to send e-mails, but I would like to know if there is any way to embed a picture in a HTML e-mail. The HTML page is generated dynamically.
 
Here's a piece of code I've used in the past to do what you're asking...


<%
Dim objMail
Set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

'//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 &quot;D:\images\myImage.gif&quot;, &quot;myImage.gif&quot;
objMail.AttachURL &quot;D:\images\myImage2.gif&quot;, &quot;myImage2.gif&quot;


HTML = HTML & &quot;<HTML>&quot;
HTML = HTML & &quot;<HEAD>&quot;
HTML = HTML & &quot;<TITLE>Send Mail with HTML</TITLE>&quot;
HTML = HTML & &quot;</HEAD>&quot;
HTML = HTML & &quot;<BODY bgcolor=&quot;&quot;lightyellow&quot;&quot;>&quot;
HTML = HTML & &quot;<TABLE cellpadding=&quot;&quot;4&quot;&quot;>&quot;
HTML = HTML & &quot;<TR><TH><FONT color=&quot;&quot;darkblue&quot;&quot; SIZE=&quot;&quot;4&quot;&quot;>&quot;
HTML = HTML & now() & &quot; - &quot;
HTML = HTML & &quot;These are all great ASP Sites</FONT></TH></TR>&quot;
HTML = HTML & &quot;<TR><TD>&quot;
HTML = HTML & &quot;<A HREF=&quot;&quot; HTML = HTML & &quot;<IMG SRC=&quot;&quot;myImage.gif&quot;&quot;></A><BR><BR>&quot;
HTML = HTML & &quot;<A HREF=&quot;&quot; HTML = HTML & &quot;<IMG SRC=&quot;&quot;myImage2.gif&quot;&quot;></A><BR><BR>&quot;
HTML = HTML & &quot;</FONT></TD></TR></TABLE><BR><BR>&quot;
HTML = HTML & &quot;</BODY>&quot;
HTML = HTML & &quot;</HTML>&quot;

objMail.From = &quot;rob@tconsult.com&quot;
objMail.Subject = &quot;Your daily HTML Mail&quot;

'you need TO add these lines FOR the mail
'to be sent in HTML format
objMail.BodyFormat = 0
objMail.MailFormat = 0

objMail.To = &quot;you@yourhouse.com
objMail.Body = HTML
objMail.Send

Response.write(&quot;Mail was Sent&quot;)
set objMail = nothing
%>

[sup]
T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
Progress2.gif

[/sup]
 
Thanks a lot I will try this and see what happens.
 
Thanks for the help I really appreciate it but it didn't work, I am working with a friend on this project and he said that he has tried that before and it didn't work. If you could give me any other ideas it would be great.
 
Well we have tried attaching the file and calling it by the image name that seems to work if the e-mail is sent to the development pc's which are on the same network as the server.

We don't want to refer the picture cause the people that get the mails aren't online the whole time and therefore wont see the picture.

I am not sure but my friend says that other code is Asp and not Asp.Net. He says that he has tried the code.

We don't get errors the image just doesn't appear.

Please help if you can.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top