Unable to convert eml to pdf

Hi , we are trying to convert eml to pdf document but unable to , it is generating the pdf file with placeholder and no images are converted in the output pdf file, kindly assist

sample code :

string dataDir = RunExamples.GetDataDir_Email();
MailMessage mailMsg = MailMessage.Load(dataDir + "sunil.eml");
MemoryStream ms = new MemoryStream();
mailMsg.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 = Words.LoadFormat.Mhtml;

// create an instance of Document and load the MTHML from MemoryStream
var document = new Aspose.Words.Document(ms, loadOptions);

// create an instance of HtmlSaveOptions and set the SaveFormat to Html
var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();
document.Save(dataDir + "1.pdf", saveOptions);

sunil.7z (12.6 KB)

Hello @sunilr80,

The issue you’re experiencing doesn’t seem to be with Aspose.Email, since the MHTML format is displayed correctly. The problem arises when converting from MHTML to PDF. This suggests that the issue is within the conversion process managed by Aspose.Words.

We have forwarded this request to the Aspose.Words forum.

@sunilr80 As I can see PDF produced by Aspose.Words is similar to PDF produced by MS Word.
Aspose.Words: out.pdf (2.6 MB)
MS Word: ms.pdf (487.0 KB)

If possible, could you please provide the expected output?

I am enclosing the sample output after the conversion please compare this to the one you have generated, the pdf outputed does not have image inside the pdf
testTotal.pdf (155.6 KB)
If possible can you share the code.

@sunilr80 I used the following simple code for testing:

Aspose.Email.MailMessage msg = Aspose.Email.MailMessage.Load(@"C:\Temp\in.msg");
msg.Save(@"C:\Temp\tmp.mhtml", Aspose.Email.SaveOptions.DefaultMhtml);
Aspose.Words.Document doc = new Aspose.Words.Document(@"C:\Temp\tmp.mhtml");
doc.Save(@"C:\Temp\out.pdf");

It looks like images on your side are not accessible and Aspose.Words cannot download them. You can try implementing IResourceLoadingCallback to control process of loading images from external resources.