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
MailMessage mailMsg = MailMessage.Load(InputFileName);
MemoryStream ms = new MemoryStream();
//Save as MHTML
//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
Right now i am using Aspose.Email version 22.214.171.124 and Aspose.Word version 126.96.36.199; As we are not in a position to upgrade the Aspsose libraries i am looking for a solutions in these versions.
Appreciate your support
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.
MailMessage message = MailMessage.Load(fileName);
MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
mhtSaveOptions.MhtFormatOptions = MhtFormatOptions.WriteCompleteEmailAddress;//this discard flag WriteOutlineAttachments