you need to add them to the email as CID resources / related resources.
here is some kind of code i used that works well in front of. Hope this gives you some tips:
Create an alternative view:
AlternateView av = AlternateView.CreateAlternateViewFromString(body, null, isHTML ? System.Net.Mime.MediaTypeNames.Text.Html : System.Net.Mime.MediaTypeNames.Text.Plain)
Create a linked resource:
LinkedResource logo = new LinkedResource("SomeRandomValue", System.Net.Mime.MediaTypeNames.Image.Jpeg); logo.ContentId = currentLinkedResource.Key; logo.ContentType = new System.Net.Mime.ContentType("image/jpg");
// add it to an alternative view
av.LinkedResources.Add(logo);
// finally add an alternative message view:
msg.AlternativeViews.Add(av);
here is some documentation to help you find out what AlternativeView and LinkedResources are and how it works:
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ system.net.mail.linkedresource (v = vs.110) .aspx http://msdn.microsoft.com/en-us/library/ms144669(v=vs.110).aspx
in the HTML itself, you need to do something like the following:
"<img style=\"width: 157px; height: 60px;\" alt=\"blah blah\" title=\"my title here\" src=\"cid:{0}\" />";
note the CID followed by the string format {0} - then I use this to replace it with a random value.
UPDATE
To come back and comment on the comments of the posters ... here is a working solution for the poster:
string body = "blah blah blah... body goes here with the image tag: <img src=\"cid:companyLogo\" width="104" height="27" />"; byte[] reader = File.ReadAllBytes("E:\\TestImage.jpg"); MemoryStream image1 = new MemoryStream(reader); AlternateView av = AlternateView.CreateAlternateViewFromString(body, null, System.Net.Mime.MediaTypeNames.Text.Html); LinkedResource headerImage = new LinkedResource(image1, System.Net.Mime.MediaTypeNames.Image.Jpeg); headerImage.ContentId = "companyLogo"; headerImage.ContentType = new ContentType("image/jpg"); av.LinkedResources.Add(headerImage); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.AlternateViews.Add(av); message.To.Add(emailTo); message.Subject = " Your order is being processed..."; message.From = new System.Net.Mail.MailAddress(" xxx@example.com "); ContentType mimeType = new System.Net.Mime.ContentType("text/html"); AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType); message.AlternateViews.Add(alternate);
// then send the message!