Closed dhrupdubey closed 2 years ago
This is expected. You will need to save the attachments first, then modify the html to point to the local file. Just to clarify, the images within the email are still attached, but attached as inline attachments rather than storage attachments.
I'm using this method:
if (message.Attachments != null) //if has attachments
{
foreach (var attachment in message.Attachments)
{
if (attachment.IsInline)
{
string attachmentPath = Path.GetTempPath() + parentUniqueId + attachment.FileName;
Debug.WriteLine("Inline Attachment: " + attachment.FileName + ", " + attachmentPath);
var attachmentFileInfo = new FileInfo(attachmentPath);
attachment.Save(attachmentFileInfo);
inlineAttachments.Add(new InlineAttachments(attachment.FileName, attachmentPath, attachment.ContentId));
}
}
}
And then using this to look for the CID string in HTML and replace it with the new local path
foreach (InlineAttachments inline in inlineAttachments)
{
Debug.WriteLine("Looking for: " + "cid:" + inline.Cid);
body = body.Replace("cid:" + inline.Cid, inline.Path);
}
@TriJoe Thanks a lot for the code, it is working now.
Closing this as this is not a bug, @TriJoe has provided solution for it.
Describe the bug Images inside .eml files are not getting added in html properly
To Reproduce Steps to reproduce the behavior:
Expected behavior Image should be shown properly in html
Screenshots Created a email adding following image
this is the result in html:
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.