How to convert MSG or EML to HTML with images for browser rendering

I have a bunch of MSG and EML files in a database that I would like to be able to render in a web browser. Many of these files have embedded images. Are there any helper methods in Aspose.Email to find img tags with src=“cid:” attributes that handle replacing the src attributes with links and retrieving the images files from the list of attchments?

Hello @Telis,

Thank you for visiting Aspose.Email support.
To save HTML with images, use the following code example:

// MSG or EML filename
var msgFileName = Path.Combine(inputPath, "my.msg");

// target HTML
var htmlFileName = Path.Combine(outputPath, "my.html");

// target directory to save images
var resourceDir = Path.Combine(outputPath, "my");

// Load MSG or EML
var msg = MailMessage.Load(msgFileName);

// Create HTML save options
var htmlSaveOptions = new HtmlSaveOptions
{
    ResourceRenderingMode = ResourceRenderingMode.SaveToFile
};

htmlSaveOptions.SaveResourceHandler +=
    (AttachmentBase attachment, out string resourceFileName) =>
    {
        if (!Directory.Exists(resourceDir))
        {
            Directory.CreateDirectory(resourceDir);
        }

        resourceFileName = Path.Combine(resourceDir, attachment.ContentType.Name);
        attachment.Save(resourceFileName);
    };

msg.Save(htmlFileName, htmlSaveOptions);