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

Free Support Forum - aspose.com

Outline-attachments not being shown in footer but keeping them listed in header

Dear Aspose-team,

could you please help me with the following issue.

I would like to extract the body of an MSG-File to a PDF document with

  • inline-attachments being kept and displayed in the body
  • outline-attachments being extracted to files
  • outline-attachments not being displayed in the footer (as image-Files are) but with their filenames remaining listed in the header

My workaround to achieve this would be:

  • extract outline-attachments to files
  • then remove outline-attachments from the MailMessage object
  • add new empty attachments with the names of the removed ones

Please find attached the solution MsgConverterGUI.zip and take a look at the following Code in Form1.cs:

private static void ConvertUsingPdf(string strMsgFile)
{
// load the MSG file using Aspose.Network for .NET
MailMessage msg = MailMessage.Load(strMsgFile,
MessageFormat.Msg);
saveOutlineAttachmentNames(msg);
removeOutlineAttachments(msg);
appendEmptyOutlineAttachments(msg);


}

I solved the problem “remove attachment from message but keep it listed in header”-problem by method

appendEmptyOutlineAttachments(msg);

It re-adds the attachments without content (zero bytes).

This workaround seems to do fine but it also seems to be a hack.
Do you know a more proper way?

Thank you very much for your excellent support,

all the best,

Stephan

Hi Stephan,

Thank you for inquiry.

I am sorry, I could not get your point clearly. Could you please also post a sample MSG file?

I checked the VS project and converted a message which had inline images and regular attachments, but the output PDF was same with or without the following 3 methods:

saveOutlineAttachmentNames(msg);
removeOutlineAttachments(msg);
appendEmptyOutlineAttachments(msg);

Hi Saqib,

thanks a lot for your immediate reply!

Please find attached Email with attachments txt doc png .zip

This MSG contains one PNG outline attachment. We would like it to appear as file name in the header of the extracted mail message but not being displayed as image in the footer.

Hence we now remove it and add new empty files with the same names to the message (our hack, the 3 lines).

Please try this MSG with and without the 3 lines - I hope the difference will appear.

Thank you so much for your help,
cheers,

Stephan

Hi Stephan,

Thanks for posting the sample message. I got your point. This is due to the conversion from MSG to MHTML format. It by default includes all text, formatting and embedded images. But, it also includes known outline attachments e.g. txt and images, so such attachments are appended at the end of the MHTML file. And when Aspose.Words load and convert this file, the outline attachments also show in the resulting PDF.

You may check the MHTML by saving it to disk and opening in a browser.
msg.Save(“test.mhtml”, MailMessageSaveType.MHtmlFromat);

You already came up with a good workaround, that is, remove outline attachments and add 0 byte with same names.

Another solution would be to customize the MSG to MHTML conversion, perhaps a boolean property like MailMessage.AddOutlineAttachmentsToMhtml. I will discuss this issue with the developers and see what can be done at our end.

Dear Saqib,
thank you very much for your efforts!

All the best,
Stephan

The issues you have found earlier (filed as 29496 ) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Please use below sample to exclude writing the attachments at the end of MHT.

msg.WriteOutlineAttachmentsToMht = false;

Hi Saqib,

excellent, thank you so much for your great support!

Cheers,

Stephan