Aspose.Mail(Version 20.10.0.0) + Aspose.Word(version 20.11.0.0) Convert Msg To PDF BUT attachments which are Images appears in output PDF

Hello Aspose supporter.
I am using Aspose.mail and Aspose.word to convert a msg file to PDF.

But I saw a problem like that
Use Case:
Precondition:

  1. A msg looks like that:
    image.jpg (79.2 KB)

  2. Code to convert msg to PDF like that:
    private static byte[] SavingAnEmailAsPdf(Aspose.Email.MailMessage mailMessage)
    {
    try
    {
    Logging.LogMessageInfo(“Start save mail to pdf”);
    MemoryStream ms = new MemoryStream();
    mailMessage.Save(ms, Aspose.Email.SaveOptions.DefaultMhtml);

             // create an instance of LoadOptions and set the LoadFormat to Mhtml
             var loadOptions = new Aspose.Words.LoadOptions();
             loadOptions.LoadFormat = LoadFormat.Mhtml;
    
             // create an instance of Document and load the MTHML from MemoryStream
             var document = new Aspose.Words.Document(ms, loadOptions);
    
             MemoryStream msPdf = new MemoryStream();
             // create an instance of HtmlSaveOptions and set the SaveFormat to Html
             var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();
             document.Save(msPdf, saveOptions);
             Logging.LogMessageInfo("Save mail to pdf successfully");
             return msPdf.ToArray();
         }
         catch (Exception ex)
         {
             Logging.LogMessageInfo("Save mail to pdf failed: " + ex.ToString());
             return null;
         }
     }
    

Test 1:
Aspose.mail(Version 20.10.0.0) + Aspose.word (Version 20.11.0.0)

Output PDF contains image of attachment.
-> This is NOT okay.
Watch output pdf here:
EmailOutputByLatestAsposeVersion.pdf (857.7 KB)

Test 2:
Aspose.mail(Version 20.9.1.0) + Aspose.word (version 17.9.0.0)

Output PDF does NOT contain image of attachment.
-> This is okay.
Watch output pdf here:
EmailOutputByOldAsposeVersion.pdf (569.8 KB)

Looks like there is a bug in combination Aspose.mail(Version 20.10.0.0) + Aspose.word (Version 20.11.0.0).
Can you please check if you get the same problem?

Thank for your support and feedback.
Yours,
Nghia

@nguyen.xuan.nghia

After observing the two PDF files and Image, it seems to be an issue that needs investigation. First of all, can you please try using Aspose.Email for .NET 20.12 and Apsose.Words for .NET 20.12 on your end. Secondly, please save MHTML to file rather stream when exporting using Aspose.Email. If the MHTML is fine and PDF has got issue then it is Aspose.Words related issue. Otherwise, if there is issue in MHTML then it is Aspose.Email related issue.

Thank for your feedback.
I tried two things:

  1. try using Aspose.Email for .NET 20.12 and Apsose.Words for .NET 20.12
    -> Still has a problem

  2. try to save MHTML to file
    -> I understand your idea, but I do not know to check if MHTML is fine or not

That is information from me.

Thank for checking deeper in your side.

@nguyen.xuan.nghia

Can you please share the source MSG/EML file that we may verify on our and log the ticket.

You can open the MHTML ouput in Browser or in MS Word. You can compare the visible output of MHTML with that of viewed in Source file. MHTML is intermediate format for rendering EML/MSG to PDF. So, if the problem is in MHTML file then its Aspose.Email issue. Otherwise, if MHTML is rendered fine but PDF has issue then it Aspose.Words issue. I hope it will make sense now.

@mudassir.fayyaz
I attach two files for you.

  1. Msg file which I did the test.
  2. Output mhtml of msg file which I saved use Aspose.Email for .NET 20.12.

You can download files by the link below:
OutputTestMsgToPDF.zip (544.3 KB)

@nguyen.xuan.nghia

Can you please try using the suggested options on your end as given in following link.

@mudassir.fayyaz
Thank you very much for your answer.
I tried your suggestion solution and it works for me.
Thank you again.

@nguyen.xuan.nghia

It’s good to know that suggested option worked on your end.