1

I am trying to send email from my ASP.NET Web forms application and the email body has an image. I followed the below discussion and able to set the image as base64-data string.

embedding image in html email

After setting the image src in HTML template (used for building email content), I am using the following c# code for setting the cid value.

C#

 AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<img src=cid:applogo>", null, "text/html");
 LinkedResource logo = new LinkedResource(@"\\app\images\emailheader.png");
 logo.ContentId = "applogo";
 htmlView.LinkedResources.Add(logo);

 mailMessage.AlternateViews.Add(htmlView);

What Works:

The image is displaying properly when the email is viewed in a browser.

Issue:

The image is not displaying when the email is viewed in Outlook 2010.

Question:

Is there any setting I need to apply or is there any compatibility issue?

Community
  • 1
  • 1
JGV
  • 5,037
  • 9
  • 50
  • 94

2 Answers2

1

The code with the mso conditional fix

<table style="width: 100%;" width="100%">
   <tr>
      <td style="text-align: left; width: 50%;" width="50%">
<h1 style="color: #12646d !important;" mc:edit="newslettername">YOUR NEWSLETTER NAME</h1>
</td>
<td style="position: relative; text-align: right; width: 50%;" width="50%">
<a href="http://iteams.us" style="border: 0; text-decoration:none;">

   <!--[if mso]>
      <table width="50%"><tr><td><img width="200" src="https://gallery.mailchimp.com/c2ce47add15fcafd7072b3dd2/images/d8ac365e-7397-4bb1-ba7f-a1cacdd78cfd.png" alt="ITEAMS" style="text-align: right; width: 207px; border: 0; text-decoration:none; vertical-align: baseline;"></td></tr></table>
      <div style="display:none">
   <![endif]-->
<img id="ITeamsLogo" src="https://gallery.mailchimp.com/c2ce47add15fcafd7072b3dd2/images/d8ac365e-7397-4bb1-ba7f-a1cacdd78cfd.png" alt="ITEAMS" style="text-align: right; min-width: 50px; max-width: 207px; border: 0; text-decoration:none; vertical-align: baseline;">
   <!--[if mso]>
      </div>
   <![endif]-->
</a>
</td>
   </tr>
</table>
Hariharan AR
  • 1,386
  • 11
  • 20
0

Outlook uses Word for rendering HTML content of Outlook emails. You can try to use Word for checking whether an image is shown or not.

You need to add an image as a hidden attachment to be able to view it in Outlook.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Eugene, thanks for the response. Can you provide details on adding an image as a hidden attachment ? I tried in google but, could not locate an answer. – JGV Feb 21 '17 at 18:25