c# - 图像和样式未出现在 HTML 电子邮件中

标签 c# html css .net

我的图像和样式没有出现在电子邮件中(在 Outlook 2016 中)。我就是这样做的:

c#:

var body = File.ReadAllText("c:/emailtemplate.html");
MailMessage msg = new MailMessage("noreply@mycompany.com", "you@outlook.com", "test", body);
msg.IsBodyHtml = true;
var client = new SmtpClient(SmtpHost);
client.Send(msg);

电子邮件模板.html

<div style="border:solid 1px #000;padding:20px;">
   <img src="logo.png" style="width:250px">
   <p style="color:red;font-weight:bold">Thanks for signing up!</p>
</div>

logo.png 与 emailtemplate.html 位于同一位置

知道如何包含图像并将样式应用到我的电子邮件吗?

最佳答案

使用图像的完整 URL 而不是其相对 URL。

类似于:http://www.example.com/logo.gif

关于c# - 图像和样式未出现在 HTML 电子邮件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37398374/

相关文章:

javascript - 为多个图像添加 HTML5 Canvas 黑白效果

html - Canvas 上的文本位置很奇怪

c# - Razor Pages 中确认模态之后的信息模态

c# - 有时上下键在 DataGridView 上不起作用

c# - 在 C# 6 中声明使用字符串插值的长字符串

javascript - jQuery 在 IE7 中不生成 DIV

javascript - HTML5 : Start counter

c# - 添加到列表后修改项目不会更新列表

html - 白皮书 : How to center two images (they change by hover effect)?

html - 高度为 100% 的固定 div 的相等缩进