CID image embeds are not loading properly in Outlook but load properly in Gmail

Mary Joy Quijano 0 Reputation points
2025-06-24T12:15:52.9433333+00:00

User's image

We are using CID to load the images, but the images won't load in outlook, we are using IFluentEmail.

var attachments = new List<Attachment>();

// Set image src then Get image src for email purpose

htmlNode.SetAttributeValue("src", $"cid:{imgIndex}");

template = template.Replace(imgHtml, htmlNode.OuterHtml);

attachments.Add(new Attachment

{

ContentId = imgIndex,

Data = new MemoryStream(Convert.FromBase64String(src.Split(";base64,")[1])),

ContentType = "image/jpeg",

Filename = $"c2p-img-{imgIndex}",

});

var templateLayout = $@" @model {model.GetType().FullName}

{template}";

sendEmailTo = recipientEmail?.Address?.ReplaceEmptyString() ?? bccEmailAddress.Address.ReplaceEmptyString();

email.FEmail.To(sendEmailTo)

.Subject(subject)

.Attach(attachments)

.UsingTemplate(templateLayout, model);

Developer technologies C#
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.