【问题标题】:Embedding image in html is not working in Outlook 2010在 html 中嵌入图像在 Outlook 2010 中不起作用
【发布时间】:2017-07-10 09:39:55
【问题描述】:

我正在尝试从我的 ASP.NET Web 表单应用程序发送电子邮件,并且电子邮件正文包含图像。我按照下面的讨论,能够将图像设置为 base64 数据字符串。

embedding image in html email

在 HTML 模板(用于构建电子邮件内容)中设置图像 src 后,我正在使用以下 c# 代码来设置 cid 值。

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);

什么有效:

在浏览器中查看电子邮件时,图像显示正常。

问题:

在 Outlook 2010 中查看电子邮件时,图像不显示。

问题:

我需要应用任何设置还是有任何兼容性问题?

【问题讨论】:

  • 您解决了这个问题吗?现在我正面临这个问题。

标签: html asp.net image email outlook


【解决方案1】:

Outlook 使用 Word 呈现 Outlook 电子邮件的 HTML 内容。您可以尝试使用 Word 来检查图像是否显示。

您需要将图像添加为隐藏附件才能在 Outlook 中查看。

【讨论】:

  • 尤金,感谢您的回复。您能否提供有关将图像添加为隐藏附件的详细信息?我在谷歌上试过,但找不到答案。
【解决方案2】:

带有 mso 条件修复的代码

<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>

【讨论】:

    猜你喜欢
    • 2012-07-31
    • 2011-09-07
    • 1970-01-01
    • 2015-03-28
    • 2013-08-01
    • 2021-11-26
    • 1970-01-01
    • 2012-02-17
    • 2016-05-11
    相关资源
    最近更新 更多