如何在Outlook客户端中显示的html邮件中制作图像? [英] how to make images in html mail presented in outlook client?

查看:475
本文介绍了如何在Outlook客户端中显示的html邮件中制作图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个html,我以邮件的形式发送(请参阅小提琴),在其中我使用2个外部图像(一个用于公司徽标,一个用于表格背景)::

I've this html which i'm sending as a mail (see fiddle) in which i use 2 external images (one for the company logo and one for the table background) : :

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 Client中不显示图片:

I send it from code to many email clients : gmail, yahoo, ios. Only in outlook client the pictures are not presented:

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

How can I overcome it? Is this related to the way I'm sending it (via c# code) or the way the images are linked to the html?

我会逐步感谢您回答。
问候,
Omer。

I'd appreciate a step by step answer. Regards, Omer.

推荐答案

这就是我如何在Outlook中使用它的方法

This is how I got this working in 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为:

The HTML to reference the above image is:

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

headerImageId 是指LinkedResource的ContentId。

the headerImageId refers to the ContentId of the LinkedResource.

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

Basically you're converting the image to text for transfer which gets re-constituted as an image on arrival at the client.

这篇关于如何在Outlook客户端中显示的html邮件中制作图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆