ASP.NET-MVC Page: image logo is not displaying while sending the email
I have a page that sends an email on ASP.NET MVC Page.
All the Text is displaying but the image is not displaying.
Any workaround.
Appreciate your responses.
Here is my code:
MailMessage mailMsg = new MailMessage();
mailMsg.IsBodyHtml = true;
mailMsg.From = new MailAddress(ConfigurationManager.AppSettings["Email.Sender"]);
mailMsg.To.Add(new MailAddress(email));
mailMsg.Subject = "Test mail to display the Logo in the email";
mailMsg.Body = " Test mail to display the Logo in the email;
mailMsg.Body += Environment.NewLine + Environment.NewLine +
"<html><body><img src=cid:companylogo/><br></body></html>";
//Insert Logo
string logoPath = Server.MapPath(Links.Content.images.Amgen_MedInfo_Logo_jpg); 开发者_如何学运维 // logo is placed in images folder
LinkedResource logo = new LinkedResource(logoPath);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display logo
AlternateView aView = AlternateView.CreateAlternateViewFromString(mailMsg.Body, new System.Net.Mime.ContentType("text/html"));
aView.LinkedResources.Add(logo);
mailMsg.AlternateViews.Add(aView);
mailMsg.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SMTP"]);
smtpClient.Send(mailMsg);
Have you checked the source of the received e-mail to see if the image is referenced correctly?
If it is then it's highly likely that the mail client is blocking the display of remote images.
精彩评论