C# 为什么嵌入图像不';t通过电子邮件发送
我试图用c#通过电子邮件发送图像,但消息中是空的,尽管它成功地附加到了电子邮件中C# 为什么嵌入图像不';t通过电子邮件发送,c#,email,html-email,C#,Email,Html Email,我试图用c#通过电子邮件发送图像,但消息中是空的,尽管它成功地附加到了电子邮件中 public static void EmailActivateMessage(string email, string token, string id, string userName) { LinkedResource resource = new LinkedResource(HttpContext.Current.Server.MapPath("~/Content/images/home/logo
public static void EmailActivateMessage(string email, string token, string id, string userName)
{
LinkedResource resource = new LinkedResource(HttpContext.Current.Server.MapPath("~/Content/images/home/logo.gif"), MediaTypeNames.Image.Gif);
resource.ContentId = "LogoPicture";
AlternateView altView = AlternateView.CreateAlternateViewFromString(ActivationText(id, token, userName), null, MediaTypeNames.Text.Html);
altView.LinkedResources.Add(resource);
MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("SquirrelsStore", "BusinessMoney");
mail.From = new MailAddress("SquirrelsStore@gmail.com");
mail.To.Add(email);
mail.Subject = "Activation Mail";
mail.AlternateViews.Add(altView);
smtp.Send(mail);
}
这是html的一部分,其中图像为空
<tr>
<td style="font-family: sans-serif;font-size: 16px !important;vertical-align: top;">
<img width="100" height="100" src=\"cid:LogoPicture\" style="border: none;-ms-interpolation-mode: bicubic;max-width: 100%;">
</td>
<td style="vertical-align: middle;font-family: sans-serif;font-size: 16px !important;">
<a href="http://link.com" style="font-size: 40px;text-decoration: none; color: #fe980f; outline-style: none;">Текст</a>
</td>
</tr>
当读取对的更改时
src=\\\"cid:LogoPicture\\\"
所以\
符号绝对是多余的
src=\\\"cid:LogoPicture\\\"