Inconsistent timestamp between sent and unsent email


Environment:

  • Aspose.Email.dll 16.10.0.0
  • email client Outlook 2016 with Exchange Server
  • timezone UTC+01

Test steps:

  • make a new email and send it to yourself
  • save the received email as an msg file - see file demo.msg in attachment
  • try to convert the demo.msg file to pdf

Test code:

MailMessage msg= MailMessage.Load(“c:\temp\demo.msg”);
MhtSaveOptions mailSaveOptions = SaveOptions.DefaultMhtml;

mailSaveOptions.MhtFormatOptions = MhtFormatOptions.None | MhtFormatOptions.WriteCompleteEmailAddress | MhtFormatOptions.WriteCompleteFromEmailAddress | MhtFormatOptions.WriteCompleteToEmailAddress | MhtFormatOptions.WriteCompleteCcEmailAddress;

MhtMessageFormatter mailFormatter = new MhtMessageFormatter();
mailFormatter.FromFormat = "<span class=“headerLineTitle”>Von:<span class=“headerLineText”> {0}
"; //Wichtig: korrekte Anführungszeichen " benutzen
mailFormatter.DateTimeFormat = “dd.MM.yyyy HH:mm”;
mailFormatter.SentFormat = “<span class=“headerLineTitle”>Gesendet:<span class=“headerLineText”> {0}
”;
mailFormatter.ToFormat = “<span class=“headerLineTitle”>An:<span class=“headerLineText”> {0}
”;
mailFormatter.SubjectFormat = “<span class=“headerLineTitle”>Betreff:<span class=“headerLineText”> {0}
”;
mailFormatter.BccFormat = “<span class=“headerLineTitle”>Bcc:<span class=“headerLineText”> {0}
”;
mailFormatter.CcFormat = “<span class=“headerLineTitle”>Cc:<span class=“headerLineText”> {0}
”;
mailFormatter.AttachmentFormat = “<span class=“headerLineTitle”>Anlagen:<span class=“headerLineText”> {0}
”;

mailFormatter.Format(msg);

msg.Save(“c:\temp\demo.mht”, mailSaveOptions);

Aspose.Words.LoadOptions loadOpt= new Aspose.Words.LoadOptions();
loadOpt.LoadFormat = LoadFormat.Mhtml;
Aspose.Words.Document doc = new Document(“c:\temp\demo.mht”, loadOpt);
doc.Save(“c:\temp\demo.pdf”, SaveFormat.Pdf);

In the pdf document the timestamp is 08:35 but it schould be 09:35.



Same observations:
  • the error is caused by the *.msg to *.mht conversion
  • the error doesn’t occur when you try an email wich was sent by another person
  • maybe the error is the same as in https://forum.aspose.com/t/20705


Yes, it seems to be the same issue i have in the other thread you mention.

By setting your own DateTimeFormat
>>mailFormatter.DateTimeFormat = "dd.MM.yyyy HH:mm";
you are overriding the display of the timezone information. which is something like "+0100" or "+0000"
So the time is actually correct.

Still Aspose should convert the two messages the same way. Or allow us to set the timezone for display.

This ist not true.

The test code without MhtMessage.DateTimeFormat produces something like this


Hi Caroline,


Aspose.Email API converts to MHTML with UTC time as default. However, you can use the TimeZoneOffset property of MailMessage to set your desired timezone while converting to MHTML. Please have a look at the documentation section, Exporting to MHT with customized Timezone, for further reference in this regard and let us know if we could be of any additional help to you in this regard.

That was my missing detail … now it works flawless.

Thanks a lot, Martin

Hi Martin,


You are welcome.