为什么嵌入图像不通过电子邮件发送

Why embed image doesn't sends through 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.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\" 

while read 更改为

src=\\"cid:LogoPicture\\"

所以\标志肯定是多余的