Author |
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 4:57am | IP Logged
|
|
|
Hi - our app has been working really well with IMAP - thanks for your help in getting it implemented.
We've just come across a problem related to British Summertime (Daylight Saving Time) however, namely that emails in our app are appearing to be +1 hour out.
We record THREE date-related fields for emails :-
- composeddt
- receiveddt
- sentdt
Here's the code which saves these date fields from a MailBee Envelope (env) object :-
Code:
try { emaili.composeddt = new DateTime(env.Date.Ticks, DateTimeKind.Utc).ToLocalTime(); }
catch (MailBee.MailBeeException)
{
try { emaili.composeddt = new DateTime(env.DateReceived.Ticks, DateTimeKind.Utc).ToLocalTime(); }
catch (MailBee.MailBeeException) { emaili.composeddt = DateTime.Now; }
}
try { emaili.receiveddt = new DateTime(env.DateReceived.Ticks, DateTimeKind.Utc).ToLocalTime(); }
catch (MailBee.MailBeeException) { emaili.receiveddt = DateTime.Now; }
try { emaili.sentdt = new DateTime(env.Date.Ticks, DateTimeKind.Utc).ToLocalTime(); }
catch (MailBee.MailBeeException) { emaili.sentdt = null; } |
|
|
It all worked perfectly before DST kicked in for British Summertime.
Please can you tell me what I'm doing wrong and how to fix it?
Many thanks!
Hedley
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 30 March 2017 at 5:06am | IP Logged
|
|
|
Are you on the latest version of MailBee.NET Objects (v11)?
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 5:47am | IP Logged
|
|
|
No I'm on 10.0.2.551
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 5:48am | IP Logged
|
|
|
Sorry - I meant 10.0.45.551 (that's the DLL version number of MailBee.NET.45.Min)
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 30 March 2017 at 6:00am | IP Logged
|
|
|
Please confirm this issue remains with the latest version. Thanks!
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 6:40am | IP Logged
|
|
|
Hi - my maintenance contract had lapsed so I have renewed it, but I only have a key for version 10. Please can you send me a version 11 key?
Thanks.
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6103
|
Posted: 30 March 2017 at 6:42am | IP Logged
|
|
|
Have just sent one via HelpDesk.
--
Thanks,
Igor, AfterLogic Support
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 7:31am | IP Logged
|
|
|
Thanks - OK - all upgraded to v11 and the problem still persists.
The problem is obviously related to the way that I am getting the dates out of the ENVELOPE :-
Code:
new DateTime(env.DateReceived.Ticks, DateTimeKind.Utc).ToLocalTime(); |
|
|
I'm honestly not sure where I got that code from - my guess would be that I copied it from one of the demonstration projects.
What is the correct way to process the envelope DateTime objects in order to get the correct local time (taking DST into consideration)?
Thanks.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 30 March 2017 at 7:35am | IP Logged
|
|
|
Please prepare a simple code like
MailMessage msg = new MailMessage();
msg.LoadMessage("msg.eml");
Console.WriteLine(msg.Date);
make sure the issue is still here and send us:
- msg.eml in question to let us reproduce the issue (via Helpdesk).
- Your output
- Expected output
Thanks!
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 7:56am | IP Logged
|
|
|
Here are some test results of an email sent at 15:51, hence that's the time I expect to see...
----------------------------------------
TEST : env.Date;
RESULT: 30/03/2017 15:51:37
TEST : new DateTime(env.Date.Ticks, DateTimeKind.Utc);
RESULT: 30/03/2017 15:51:37
TEST : new DateTime(env.Date.Ticks, DateTimeKind.Utc).ToLocalTime();
RESULT: 30/03/2017 16:51:37
TEST : new DateTime(env.Date.Ticks, DateTimeKind.Local);
RESULT: 30/03/2017 15:51:37
TEST : new DateTime(env.Date.Ticks, DateTimeKind.Local).ToLocalTime();
RESULT: 30/03/2017 15:51:37
----------------------------------------
Presumably the DateTime objects on a MAILBEE Envelope (or MailMessage) are stored in UTC, so which of the above is the recommended way to adjust the time to the user's locale?
Many thanks.
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 30 March 2017 at 8:27am | IP Logged
|
|
|
OK - sorted it myself. Dates are not stored as UTC unless :-
So that's what I needed.
|
Back to Top |
|
|