MhtMessageFormatter doubles the headers

Hi,


I am using MhtMessageFormatter in order to change the date format. But, in the output mhtml file I have the headers two times (one formatted and one not). What am I doing wrong? My source code looks like this:

var doc = MailMessage.Load(input);
doc.TimeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(doc.Date);
var formatter = new MhtMessageFormatter();
formatter.DateTimeFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
formatter.Format(doc);
doc.Save(output, SaveOptions.DefaultMhtml);

input files: “line breaks.msg” or "line breaks.eml"
output files: “line breaks.mhtml” and "screenshot.explorer.png"
Aspose.Email version is 5.4.0.0

Best Regards,
Vassil

Hi Vassil,

Thank you for writing to Aspose support team.

MhtSaveOptions should be used where headers information is to be configured. You may please use MhtFormatOptions.HideExtraPrintHeader, to hide the extra headers. Could you please give a try to the following sample code and let us know the feedback?

var doc = MailMessage.Load(path + "linebreaks.msg");
doc.TimeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(doc.Date);
var formatter = new MhtMessageFormatter();
formatter.DateTimeFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
formatter.Format(doc);
MhtSaveOptions options = new MhtSaveOptions();
options.MhtFormatOptions = MhtFormatOptions.HideExtraPrintHeader;
options.MailMessageSaveType = MailMessageSaveType.MHtmlFormat;
doc.Save(path + "Output.mht", options);
I was not aware of the correct options.

Thanks a lot!
Vassil

Hi Vassil,


Thank you for providing the feedback. Please feel free to write us back for any other query related to Aspose.Email.