I have a requirement to display image in the letter of the SMTP Mail in C#.net ? How To Add image in the letter head of the Email by smtp mail message object in c #.net through programatically ?
Asked
Active
Viewed 394 times
-3
-
Check this out: http://stackoverflow.com/questions/1212838/c-sharp-sending-mails-with-images-inline-using-smtpclient – animaonline Feb 08 '13 at 09:22
1 Answers
1
You can use the ContentID of the IMAGE tag to reference an image in the HTML body of your email like this:
<IMG SRC="cid:content-id" />
Then you add the image as a linked resource to the alternateviews part of the mailmessage:
AlternateView body = AlternateView.CreateAlternateViewFromString(m_msg.Body,null,"text/html");
//create the LinkedResource (embedded image)
LinkedResource embimg= new LinkedResource(filename,System.Net.Mime.MediaTypeNames.Image.Jpeg);
logo.ContentId = cid; // content-id used in image tag
body.LinkedResources.Add(embimg);
m_msg.AlternateViews.Add(body);

Gnor
- 61
- 2