0

In the HTML there are two images:

<IMG SRC="cid:#IMG01#" >
<IMG SRC="cid:#IMG02#" >

The C# code is:

                var message = new MailMessage
                {
                    Priority = MailPriority.Normal,
                    Sender = new MailAddress(utente.Email, "xxx.it"),
                    From = new MailAddress(utente.Email, "xxx.it")
                };
                message.To.Add(new MailAddress("xxx@tiscali.it", "aaaaaaaa"));

                message.Subject = "xywz";
                message.IsBodyHtml = true;
                message.Body = Modello;

                Attachment AttPrinc = new Attachment(path + "Attachment.pdf");
                message.Attachments.Add(AttPrinc);

                string contentID1 = "IMMAGINE01";
                string contentID2 = "IMMAGINE02";

                Modello = Modello.Replace("#IMG01#", contentID1);
                Modello = Modello.Replace("#IMG02#", contentID2);

                LinkedResource InlineImg01 = new LinkedResource(path + "img01.jpg", "image/jpg");
                InlineImg01.ContentId = contentID1;
                LinkedResource InlineImg02 = new LinkedResource(path + "img02.jpg", "image/jpg");
                InlineImg02.ContentId = contentID2;

                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Modello, null, "text/html");
                htmlView.LinkedResources.Add(InlineImg02);
                htmlView.LinkedResources.Add(InlineImg01);                    
                message.AlternateViews.Add(htmlView);

                var mailClient = new SmtpClient();
                mailClient.Send(message);

I send the email and, on my PC with Thunderbird, I see all correct, on my PC with the webmail, I see the images, on my phone (Huawey Mate 8) with webmail, I don't see the images. I send the email to other persons (tester), and some of them can see the images, some others can't see the images. I'm going crazy.

Any suggestion?

Giorgio Forti
  • 131
  • 2
  • 14
  • 1
    Is the path a URL or inside a network using a network path? If network path it is probably an access/permission issue where the people not seeing it do not have access to them. – Brad Apr 05 '18 at 19:51
  • The images are being embedded in the message as a linked resource, so it's not a network issue. It's likely an issue with their e-mail clients. Not all clients support embedded images or the different ways to embed images. That's just the nature of e-mail. See if this helps: https://stackoverflow.com/questions/6706891/embedding-image-in-html-email – Dan Wilson Apr 05 '18 at 20:24
  • You may have issues with the different codec on different computers. I would try to put files on a memory stick and copy between computers to see if the file displays correctly on non working computers. Also check byte count of files to see if the file size changes when sending by email. – jdweng Apr 05 '18 at 23:41

1 Answers1

0

After long hours of debug, I found the problem: the HTML file was generated by Word ... I rewrote the file from scratch and magically all works well everywhere.

The HTML code generated by Word was something insane, classes and classes, all for a simple document.

Giorgio Forti
  • 131
  • 2
  • 14