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

Free Support Forum - aspose.com

.msg saveas .mhtml => sent date not correct

Hi Aspose,

I use a code to convert an .msg file into an .mhtml format before convert to PDF file.

The sent date of mhtml is not correct during the convertion, dus also incorrect in my PDF.

sent date of MAIL : lun. 26/10/2015 09:03

sent date of mhtml : 26 Oct 2015 08:03:00 +0000

I use the version 5.8 of Aspose.Email.

The code:

private void cmdConvertMhtml_Click(object sender, EventArgs e)


using (MailMessage mailMsg = MailMessage.Load(Email.Text, new MsgLoadOptions()))


mailMsg.Save(Email.Text.Replace(".msg", “.mhtml”), Aspose.Email.Mail.SaveOptions.DefaultMhtml);



In attach the .mhtml and .msg files and a capture of the result.

Thanks for your support

Hi Fabien,

Thank you for posting your query.

This is an expected behavior. When a message is converted to MHTML, the output mhtml file is added time with respect to UTC. Thus, the time offset is adjusted as per UTC difference and the adjusted time is printed in the output MHTML file.

thanks for your answer.

In this case how can i convert my message into PDF with the same value of the date sent ?

Hi Fabien,

Here a sample code is given which adds the system timezone in the message timezone offset before converting it to Mhtml. In this way the resultant Mhtml and PDF contain sent date similar to original message. Please give it a try and let us know the feedback.


MailMessage inputMsg = MailMessage.Load("PDFC000179053973.msg");

MemoryStream msMHTML = new MemoryStream();

TimeZone localZone = TimeZone.CurrentTimeZone;

TimeSpan ts = localZone.GetUtcOffset(DateTime.Now);

inputMsg.TimeZoneOffset += TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);

MhtMessageFormatter mhtlFormat = new MhtMessageFormatter();

mhtlFormat.DateTimeFormat = "ddd MM/dd/yyyy hh:mm tt";


// Save as mht with header

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

mhtSaveOptions.MhtFormatOptions = MhtFormatOptions.None;

mhtSaveOptions.MhtFormatOptions = mhtSaveOptions.MhtFormatOptions | MhtFormatOptions.HideExtraPrintHeader;

inputMsg.Save("output.mht", mhtSaveOptions);

inputMsg.Save(msMHTML, mhtSaveOptions);

Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();

loadOptions.LoadFormat = Aspose.Words.LoadFormat.Mhtml;

dynamic document = new Aspose.Words.Document(msMHTML, loadOptions);

dynamic saveOptions = new Aspose.Words.Saving.PdfSaveOptions();

document.Save("output.pdf", saveOptions);