Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how to send email which contain HTML attachment with images?
Posted
Comments
Sergey Alexandrovich Kryukov 2-Mar-12 3:20am    
This is something good to know, and it was not absolutely easy to find out, so I voted 5 for the question.
--SA

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Mar-12 3:22am    
What's funny, the first sample is exactly the same as the one in my answer, but from different source. My 5.
But I also explained the background, please see.
--SA
softprga 2-Mar-12 5:19am    
Image is inside html document.
and send that html.when html doc open ,image will display in html page.
Here is the background: the images in HTML e-mail should be referenced using the special URI scheme "cid:" (Content-id). Please see:
http://en.wikipedia.org/wiki/URI_scheme[^],
http://tools.ietf.org/html/rfc2392[^].

The e-mail should be a multipart e-mail. Some parts could be HTML documents and some — base64-encoded images. To reference an image in one part in HTML part, HTML code <img> tag should reference the image as cid:<content-id></content-id>, where content-id should be the same as LinkedResource.ContentId of the image part to be referenced and thus rendered as inserted in HTML document.

This example illustrates using this technique for creation of e-mail with C# and .NET:
http://kosiara87.blogspot.com/2011/04/c-sending-mail-with-embedded-image.html[^].

(This is a pretty dumb code; it uses a placeholder "@@IMAGE@@" in the HTML code to be replaced with actual value for content id using string.Replace, instead of, say, using string.Format. It has nothing to do with the idea of embedding the images.)
I found this example using this query: http://bit.ly/zpvER5[^].

If you need more advanced example, try to find some more; it returned just about 227,000 results.

—SA
 
Share this answer
 
v3
Comments
ProEnggSoft 20-Mar-12 0:19am    
Good solution. +5
Sergey Alexandrovich Kryukov 20-Mar-12 1:07am    
Thank you again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900