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

Free Support Forum - aspose.com

What value is used for MailMessageSaveOptions if not specified in save method?

I used the public void Save ( Stream stream, MailMessageSaveType savetype ) method to save my emails to mht. Using this method sometimes some attachments where saved into the the mht. Now I am handling attachments separately.


Because of this, I want to prohibit that any attachments are saved into the mht. I know that _mailMessage.Save(msgStream, MailMessageSaveType.MHtmlFormat, MailMessageSaveOptions.None) or _mailMessage.Save(msgStream, MailMessageSaveType.MHtmlFormat, MailMessageSaveOptions.WriteHeaderToMht) does the job (as do other Flag combinations).

What I want to know now, is, which flag combination do I have to use to get the same behavior with this method public void Save ( Stream stream, MailMessageSaveType savetype, MailMessageSaveOptions saveOptions ) as I did before when I used this method public void Save ( Stream stream, MailMessageSaveType savetype )?

It is not MailMessageSaveOptions.None, as one might expect, because this does not save the email header. With the old save method the header was saved.



Hi Peter,

Thank you for posting your inquiry to Aspose support team.

The MhtSaveOptions is the alternative for using in this case. Please have a look at the following code sample for your kind reference which is also posted here in our online documentation.

Sample Code:

MailMessage eml = MailMessage.Load(Path.Combine(directoryPath, “test.eml”));


// Save as mht with header

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions

{

MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.HideExtraPrintHeader

};


eml.Save(Path.Combine(directoryPath, “outTest.mht”), mhtSaveOptions);