0 down vote favorite

I am trying send Newsletter with images, I am able to send email but not getting images, I tried to search lots of solution but its not working.Please check this link for

When I am trying to email this newsletter, I am getting newsletter without images. I put hard coded images in html file, like <img src= /> Here my simple code for sending email :

MailMessage myMail;

using (StreamReader reader = File.OpenText(Server.MapPath("Newsletter.html"))) // Path to your 
{                                                         // HTML file
    myMail = new MailMessage();
    myMail.From = new MailAddress("email@domain.com.au");
    myMail.Subject = "Test News Letter";
    myMail.To.Add("se@yahoo.com.au");
    myMail.IsBodyHtml = true;

    myMail.Body = reader.ReadToEnd();  // Load the content from your file...

}
SmtpClient smtp = new SmtpClient("xx.xx.xx.y", 25);
smtp.UseDefaultCredentials = true;

NetworkCredential cred = new NetworkCredential("email@domain.com.au", "hakoo");
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = cred;
smtp.Send(myMail);

Can anyone help me to solve this issues?

Thanks,

Hakoo Desai.

Dani AI

Generated

A few likely causes and a practical fix

— when recipients get the HTML but no images it is usually one of three things: the email client is blocking remote images by default, the image URLs are not actually publicly reachable (firewall, hotlink protection or auth), or the newsletter HTML needs images embedded so they travel with the message. pointed to some how‑tos; the two practical approaches are (A) keep remote images but make sure they are publicly reachable over HTTPS and check your server logs for GETs, or (B) embed images inline using CID/LinkedResource so the images are attachments referenced from the HTML.

Quick debugging checklist

  • Paste each image URL into a private/incognito browser and confirm a 200 OK (no auth, no redirects to login).
  • Open the raw/original source of a received message (View original in Gmail / Message Options in Outlook) and verify the <img> src values are what you expect.
  • Check the webserver access logs to see if the image is being requested when the message is opened. No request = client blocked images or bad URL.
  • If you need inline images, convert the <img src="..."> to use a CID and attach the files as linked resources.

Embedding images (core idea)

  • Change image tags to use cid:yourId (for example <img src="cid:logo">).
  • Create an AlternateView from your HTML and add LinkedResource objects with matching ContentId. Then add that AlternateView to the MailMessage. Example (only the linking part):
// html must contain <img src="cid:logo">
AlternateView av = AlternateView.CreateAlternateViewFromString(html, null, "text/html");
LinkedResource logo = new LinkedResource(HttpContext.Current.Server.MapPath("~/images/logo.jpg"), "image/jpeg");
logo.ContentId = "logo";
logo.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
av.LinkedResources.Add(logo);
mail.AlternateViews.Add(av);

Extra notes

  • Set smtp.UseDefaultCredentials = false if you supply smtp.Credentials.
  • Embedding increases message size and can affect deliverability; test with Gmail, Outlook and mobile clients.
  • If you prefer remote images, use HTTPS, confirm no hotlink rules apply, and remember many clients block remote images until the user allows them.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.