【发布时间】:2014-08-24 08:06:03
【问题描述】:
ASP.NET / Mono MVC4 C# 应用程序。 html 文档需要通过电子邮件作为附件发送。
我试过了
using (var message = new MailMessage("from@somebody.com",
"to@somebody.com",
"test",
"<html><head></head><body>Invoice 1></body></html>"
))
{
message.IsBodyHtml = true;
var client = new SmtpClient();
client.Send(message);
}
但 html 内容出现在消息正文中。 如何强制 html 内容显示为电子邮件附件?
更新
我尝试了异常回答,但文档仍然仅在邮件正文中出现在 Windows Mail 中。
消息源显示包含两部分:
----boundary_0_763719bf-538c-4a37-a4fc-e4d26189b18b
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
和
----boundary_0_763719bf-538c-4a37-a4fc-e4d26189b18b
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
这两个部分具有相同的 base64 内容。 如何强制html显示为附件?
邮件正文可以为空。
【问题讨论】:
标签: c# .net asp.net-mvc asp.net-mvc-4 email-attachments