user979331 user979331 - 5 months ago 50
ASP.NET (C#) Question

ASP.NET MVC System.Net.Mail embed image not working

I am sending an email via ASP.NET MVC 4 using System.Net.Mail and I am trying to embed an image in it like so:

message = "<br/><br/><img src='/Images/cp-map.jpg' /><br/><br/>";

MailAddress to = new MailAddress(;
MailAddress from = new MailAddress(“");
MailMessage email = new MailMessage(from, to);
email.Subject = “Subject”;
email.Body = message;
email.IsBodyHtml = true;
SmtpClient client = new SmtpClient("");

I get the email, but it does not have the image in it just a blue box with a question mark in it.....what am I doing wrong and I need to fix this asap.


The image url should be an absolute url (a url which you can copy and paste to any browser window and you will be able to see the image), not a relative url because when you open the email from any email provider's web app(ex:, it is trying to load the image from relative path which might not exist in gmail's web app.

This should work.

var imgUrl="";
message = "<br/><br/><img src='"+imgUrl+"' /><br/><br/>";

Replace yourSite with your actual site name or another domain where the images are hosted with the same url pattern.