gpt4 book ai didi

c# - 如何在 Outlook 客户端中显示 html 邮件中的图像?

转载 作者:太空宇宙 更新时间:2023-11-04 04:29:42 25 4
gpt4 key购买 nike

我有这个 html,我作为邮件发送(参见 fiddle ),我在其中使用了 2 个外部图像(一个用于公司 Logo ,一个用于表格背景): :

http://jsfiddle.net/UTSnK/

<img src="http://www.hawkaviation.com/assets/static-header.jpg" alt="Hawk Aviation""/></a>

<table border="0" cellspacing="0" cellpadding="0" style="background:rgba(55, 20, 240, 0.99) url('http://www.hisplaceautorepair.com/images/auto/Primary_Images/napa_bg.jpg'); padding: 38px">

我将它从代码发送到许多电子邮件客户端:gmail、yahoo、ios。只有outlook客户端不显示图片: enter image description here

我该如何克服它?这与我发送它的方式(通过 c# 代码)或图像链接到 html 的方式有关吗?

我会很感激一步一步的回答。问候,奥马尔。

最佳答案

这就是我在 Outlook 中实现它的方式

private MailMessage report = new MailMessage();

...

if (this.report.IsBodyHtml)
{
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(this.bodyText.ToString(), this.report.BodyEncoding, "text/html");

LinkedResource headerImageLink = new LinkedResource(ConfigReader.GetConfigValue("ImageLocation") + "\\MyBanner.gif", "image/gif");
headerImageLink.ContentId = "headerImageId";
headerImageLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;

LinkedResource footerImageLink = new LinkedResource(ConfigReader.GetConfigValue("ImageLocation") + "\\horizontal_c.gif", "image/gif");
footerImageLink.ContentId = "footerImageId";
footerImageLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;

htmlView.LinkedResources.Add(headerImageLink);
htmlView.LinkedResources.Add(footerImageLink);

this.report.AlternateViews.Add(htmlView);
}

引用上图的 HTML 是:

<IMG src=\"cid:headerImageId\"/>

headerImageId 指的是 LinkedResource 的 ContentId。

基本上,您是将图像转换为文本以进行传输,这些文本在到达客户端时会重新构造为图像。

关于c# - 如何在 Outlook 客户端中显示 html 邮件中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17528496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com