在电子邮件中嵌入背景图像
我正在尝试使用电子邮件中的嵌入图像作为背景图像,我有以下代码来嵌入它:
LinkedResource backgroundLink = new LinkedResource("..\\..\\background.gif");
backgroundLink.ContentId = "BackgroundImage";
backgroundLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
htmlView.LinkedResources.Add(backgroundLink);
m.AlternateViews.Add(htmlView);
然后在电子邮件正文中我有以下代码要测试:
<table background='cid:BackgroundImage'>
<tr>
<td>
test
</td>
</tr>
</table>
它没有t 显示,但是当我将它作为图像放入时,这样就可以了:
<table>
<tr>
<td>
<img src='cid:BackgroundImage' />
</td>
</tr>
</table>
有谁知道为什么它不会显示为背景?
非常感谢提前:)
I'm trying to use an embedded image in an e-mail as the background image, i've got the following code to embed it:
LinkedResource backgroundLink = new LinkedResource("..\\..\\background.gif");
backgroundLink.ContentId = "BackgroundImage";
backgroundLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
htmlView.LinkedResources.Add(backgroundLink);
m.AlternateViews.Add(htmlView);
Then in the e-mail body i've got the following code to test:
<table background='cid:BackgroundImage'>
<tr>
<td>
test
</td>
</tr>
</table>
It doesn't display, but when i put it in as an image like this is is fine:
<table>
<tr>
<td>
<img src='cid:BackgroundImage' />
</td>
</tr>
</table>
Does anyone one know why it won't display as a background?
Many thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请注意,MS Outlook 2007、Live Hotmail 等不支持带有背景图像的电子邮件内容,无论是正文、表格等。
在使用您的电子邮件客户端进行测试之前请检查这一点:
http://www.campaignmonitor.com/css/
Do note that MS Outlook 2007, Live Hotmail etc do not support email content with background images of an sort, be it body, tables etc.
Check this before testing with your email client:
http://www.campaignmonitor.com/css/
不幸的是,您无法在电子邮件中可靠地使用背景图像,因为许多流行的电子邮件客户端不会渲染它们。
我花了很多令人沮丧的时间试图解决这个问题,但尚未找到一个好的解决方案!
Unfortunately you cannot reliably use background images in e-mails as many popular email clients do no render them.
I've spent many frustrating hours trying to work around this and as yet have not found a nice solution!
您尝试过以下操作吗?您可以在电子邮件中使用 CSS - 只需使用背景图像属性。
我只在 Apple Mail 中测试过此片段!
Did you try the following? You can use CSS in your E-Mails - just use the background-image property.
I have tested this snippet only in Apple Mail!
使用这个
字符串 Body = "";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
Mail.AlternateViews.Add(htmlView);
之后您可以使用 smtp 设置
Use this
string Body = "";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
Mail.AlternateViews.Add(htmlView);
After this you can use smtp settings