0
我試圖通過電子郵件使用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("[email protected]");
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>