IT’s seem to be a TimeZone problem.
Do you play with the GMTOffset date property ? When saving or uploading don’t you have to set the right GMTOffset that I think is +2 in your country ?
You must read the end of the DateTime.
If the DateTime string received ends with “+0600”, the GMTOffset is 6
In order to set the right date, you must do something like that :
dim dt as new Date
dim myGMTOffset As Double
myGMTOffset = dt.GMTOffset
dt.GMTOffset = 6
set the time
set now your GMTOffset : dt.GMTOffset = myGMTOffset
Can you go to the original email, then View - Message - Raw Source and post all Received: and Date: that you see, then do the same for the uploaded email?
What date do you use when you parse the emails? I don’t see TimeZone on the posted code.
Do you always get 2 hour difference or that changes sometimes?
Parsing the date is much too complex to post here. Different email clients use slightly different dates. I modelled my code after Mail which uses the first date in the received part of the header.
I have a report from a user who complained about getting a 7 hour difference after uploading the email. When not in daylight savings time I get a one hour difference. So it must be time zone related.
Private Function makeUpdateDate(theDate as Date) as Date
if theDate = Nil then Return Nil
dim CheckDate as DateTime = theDate
dim theTimeZone as TimeZone = CheckDate.Timezone
theDate.TotalSeconds = theDate.TotalSeconds - theTimeZone.SecondsFromGMT
Return theDate
End Function
Thank you Beatrix. Is weird that the received: and date: are the same in original and uploaded, I expected a difference because I played with the date on an email received and using mail.
What I did is:
download the email to the computer
open it in a text editor
change the time on each received: date I could find (make it unique to know which one Mail used to display the date and time
change received: to received2: so next load the mail program will not use that date and time
but it looks like now you are getting the correct date.