I am getting inbox messages using Gmail API in my c# ASP.net application. All messages are from different time zones(states/countries), I wanna display there date in my own time zone as it displays in Gmail App. I searched a lot for conversion between timezones but can't solve it may be i am not getting it properly.
My code for but i tried so far is: (Its working for most of messages but for few of them its not displaying right DateTime)
For Example:
Time displayed in Gmail App: 30/11/2017 2:11 AM
My code Input/ value from Gmail API: Wed, 29 Nov 2017 10:11:35 -0800
Below are some values i am getting from my current gmail inbox messages:
var re = service.Users.Messages.List("me");
re.LabelIds = "INBOX";
re.Q = "is:all";
var res = re.Execute();
if (res != null && res.Messages != null)
{
foreach (var email in res.Messages)
{
var emailInfoResponse = service.Users.Messages.Get("me", email.Id).Execute();
if (emailInfoResponse != null)
{
foreach (var mParts in emailInfoResponse.Payload.Headers)
{
if (mParts.Name == "Date")
{
date = mParts.Value;
}
}
}
}
}
My Time Zone is: (UTC+08:00) Perth
Any help would be appreciated. Thanks!
emailInfoResponse
, but we do not have any way of knowing what that is.internalDate
field would be more reliable to work with than theDate
header. Did you try working with that?