Having an issue sending an image via email as an embedded image in the body. The image file shows as an attachment which is ok but the inline image portion just shows as a red x.
Here is what I have so far
LinkedResource inline = new LinkedResource(filePath);
inline.ContentId = Guid.NewGuid().ToString();
MailMessage mail = new MailMessage();
Attachment att = new Attachment(filePath);
att.ContentDisposition.Inline = true;
mail.From = from_email;
mail.To.Add(data.email);
mail.Subject = "Client: " + data.client_id + " Has Sent You A Screenshot";
mail.Body = String.Format(
"<h3>Client: " + data.client_id + " Has Sent You A Screenshot</h3>" +
@"<img src=""cid:{0}"" />", inline.ContentId);
mail.IsBodyHtml = true;
mail.Attachments.Add(att);
In addition to the comments above, I have the following additional comments:
"cid:att-001"
this does NOT work on iPhone (late 2016 patch level), rather use pure alpha numeric"cid:att-001" -> "cid:att001"
As an aside. Outlook (even Office 2015) rendering (still the clear majority for bussiness users) requires the use of TABLE TR TD style HTML as it down not fully support the HTML box model.
Try this
The minimal c# code to embed an image can be:
Try This.
The other solution is attaching the image as attachment and then referencing it html code using cid. HTML Code:
C# Code: