MVC 4,c#.net 使用ActionMailer.Net.Mvc.EmailResult发送电子邮件 使用smtp服务器
使用: 的 _email_layout.cshtml
<!DOCTYPE html>
<html>
<head></head>
<body>
<img alt="header.png" src="cid:header.png" />
<div id="main">
@RenderBody()
</div>
</body>
</html>
MailController.cs中的
ActionMailer.Net.Attachments.Inline.Add("header.png", System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/Content/Images/pic.png")));
ActionMAiler.Net.Mvc.EmailResult v = Email("myemailview", modelforview);
发送电子邮件:
myEmail.DeliverAsync();
如果发送到我们公司的电子邮件 - 图像会按预期显示在电子邮件中。
如果发送到gmail.com - inline pic.png不在电子邮件中。 取而代之的是&#34; header.png&#34;在它旁边和电子邮件末尾的垃圾文本。
非常感谢