We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embedded images not being rendered in HTML/PDF

Good Evening,

We have an application the uses Aspose.Email for .NET version 17.4 to render email messages as HTML, then converts the HTML to a Word Document and then a PDF document.

One of our clients reported an issue with the application not rendering an embedded image in the output PDF file. The image is inserted into the email by taking a screenshot using the Windows Snipping Tool, copying the image, and saving it into the email. When debugging the code, I noticed that the HTML file that is being loaded from the .EML file is not being rendered on the webpage. This is understandable since a web browser is not going to be able to know how to render an image with a source attribute that contains “cid:” in the beginning. However, we’d still like to be able to render these images in a PDF document.

I followed the instructions based on the following forum posts, but none of them resolved the issue:

Let me know what other code samples I could try with that version and what other information I can send to help diagnose the issue.

If you would like some sample code and the sample email that fails, please let me know. Thanks!

@tenders,

We have tested this at our end with the latest version of Aspose.Email for .NET 18.1 and were not able to reproduce the problem. The converted input MSG file contains the image of message body in output MHT and PDF.

Please share your sample message file and code you are trying at your end for further investigation at our end. We’ll look into it for assisting you further.

@kashif.iqbal,

Here is a sample piece of code:

using (var asposeMsg = Aspose.Email.MailMessage.Load(emlFileName))
{
    asposeMsg.PreferredTextEncoding = Encoding.UTF8;

    asposeMsg.Date = msg.Header.DateSent;

    using (var ms = new MemoryStream())
    {
            asposeMsg.Save(ms, Aspose.Email.SaveOptions.DefaultMhtml);
            var options = new Aspose.Words.LoadOptions { LoadFormat = Aspose.Words.LoadFormat.Mhtml };
            var pdfFileName = tempFolder.GetTempFileName("pdf");

            new Aspose.Words.Document(ms, options).Save(pdfFileName, Aspose.Words.SaveFormat.Pdf);
     }
}

Below is the attached msg file
FW Tax Assessor Office Reply to ORR Confirmation # 13708 R5147 055 Property Value.zip (508.2 KB)

Thanks for the assistance!

@tenders,

Thank you for providing the sample message file. I have tested the scenario using your sample code with latest version Aspose.Email for .NET 18.1.0 but could not re-produce the issue. All the inline images are printed fine in the PDF which is attached here for your reference. Please analyze this pdf file and if still issue is there, identify the image which is missing.

Give your code a try using latest version of Aspose.Email and share the feedback.
sample.pdf (166.4 KB)