EWS MailMessage.Date Problem

Hi,


I’m using your EWS Client to retrieve e-mails from a specific mailbox. When iterating through the collection, the Date property of the EmailMessage is always 2 Hours behind the actual date the message was received.

The TimeOffset property is all 0’d - not sure if this needs to be set. Is there a reason for the consistent 2-hours behind? The date on the Outlook Exchange server and client is set correctly.

Please advise.

Daniel

Hi Daniel,

Thank you for writing to Aspose support team.

It seems to be related to the timezone information of the local time. For example, in the screenshot, you can see the message time as 6:23 Pm as in Exchange Message box window and 1:23 PM in the console window. The difference is the timezone offset of my region. Could you please re-check the same at your end and let us know your feedback?

Hi Kashif,

I sent a mail to my mailbox. The time received on my Outlook client indicated 8:30am, and the Date property on the MailMessage indicated 6:30am.

I have not set any timezone information on my local machine. The e-mails I receive on my local machine have the correct dates.

Please advise where else I should look?

Hi Daniel,


The Outlook client shows the date in your local timezone. If you save the message as EML and open in Notepad, you will see that the Date property seems something like this:

Date: Thu, 9 Oct 2014, 14:10:12 -0500

The -0500 is the timezone offset of my region with respect to the UTC. While displaying the date using the Aspose.Email, it doesn’t adjust the offset. Please verify it at your end by downloading the message to your disc, saving it as EML and opening it in Notepad. There must be some timezone offset set by which you are seeing the difference.

Hi Kashif,

I can’t seem to save it in an EML format. Could you possibly try to [download mine ](http://www.filepimp.com/5v1)and see?

Thanks

Hi Daniel,

Outlook doesn’t allow to save the messages as EML. I have downloaded, saved and attached the sample EML here for your reference. Please let us know if we can be of any additional help to you in this regard.

Hi Kashif,

Thank you. I see what you mean now - the e-mail you attached displays as 08:37 in Outlook, but opened in notepad, the time is 11:37 +0500.

So with regards to this offset, is this being set by my local machine? My application is running as a Windows Service on a different server - do I need to change the offset on the Windows settings or in the Aspose client?

Hi Daniel,

This can be done manually at your end by adding TimeSpan offset to the message date which contains your timezone offset. You can adjust it like this:


MailMessage eml = MailMessage.Load(“ADownloaded.eml”);


Console.WriteLine(eml.Date + new TimeSpan(-2, 0, 0));

Please try it at your end by experimenting with it and let us know if we can be of any additional help to you in this regard.