Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Problems with Daylight Saving Time change Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 4:57am | IP Logged Quote hmuscroft

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 View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2159
Posted: 30 March 2017 at 5:06am | IP Logged Quote Alex

Are you on the latest version of MailBee.NET Objects (v11)?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 5:47am | IP Logged Quote hmuscroft

No I'm on 10.0.2.551
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 5:48am | IP Logged Quote hmuscroft

Sorry - I meant 10.0.45.551 (that's the DLL version number of MailBee.NET.45.Min)
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2159
Posted: 30 March 2017 at 6:00am | IP Logged Quote Alex

Please confirm this issue remains with the latest version. Thanks!

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 6:40am | IP Logged Quote hmuscroft

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 View hmuscroft's Profile Search for other posts by hmuscroft
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5750
Posted: 30 March 2017 at 6:42am | IP Logged Quote Igor

Have just sent one via HelpDesk.

--
Thanks,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 7:31am | IP Logged Quote hmuscroft

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 View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2159
Posted: 30 March 2017 at 7:35am | IP Logged Quote Alex

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 View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 7:56am | IP Logged Quote hmuscroft

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 View hmuscroft's Profile Search for other posts by hmuscroft
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 30 March 2017 at 8:27am | IP Logged Quote hmuscroft

OK - sorted it myself. Dates are not stored as UTC unless :-

Code:
env.DatesAsUtc = true;


So that's what I needed.
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide