ASP.NET-MVC Page: image logo is not displaying while sending the email
Posted
by Rita
on Stack Overflow
See other posts from Stack Overflow
or by Rita
Published on 2010-04-28T21:57:10Z
Indexed on
2010/04/28
22:07 UTC
Read the original article
Hit count: 420
Hi
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);
© Stack Overflow or respective owner