How to convert an MSG to PDF without attachments

Hi ,
I am using aspose.email and aspose.word libraries to convert an MSG file to PDF. But when i convert it using the following code, attachments are also getting inserted(which i don’t need) to the output PDF file. I am looking for just the data in the MSG file, it needs to skip the attachments

//Code snippet

MailMessage mailMsg = MailMessage.Load(InputFileName);

MemoryStream ms = new MemoryStream();

//Save as MHTML
mailMsg.Save(ms, MailMessageSaveType.MHtmlFormat);

//create an instance of LoadOptions and set the LoadFormat to Mhtml
var loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = Aspose.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();

//save the document to Html file
document.Save(OutputFileName, saveOptions);

Right now i am using Aspose.Email version 3.8.0.0 and Aspose.Word version 13.8.0.0; As we are not in a position to upgrade the Aspsose libraries i am looking for a solutions in these versions.
Appreciate your support

Thanks,
Subhash

Hi Subhash,

Thank you for writing to Aspose support team.

MhtFormatOptions contains flag WriteOutlineAttachments which is set by default.

The outline attachments are written to the output because the WriteOutlineAttachments flag is true by default. If you want to avoid the contents of the attachments to the output, you can use the MhtSaveOptions as in the following code sample. Please try it at your end and let us know your feedback.

Sample Code:


MailMessage message = MailMessage.Load(fileName);

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

mhtSaveOptions.MhtFormatOptions = MhtFormatOptions.WriteCompleteEmailAddress;//this discard flag WriteOutlineAttachments

message.Save(mhtFileName, mhtSaveOptions);