IMAP Date Time Header showing different date format and not recognise

Hi All,
I am getting issue when I am getting date from Gmail through IMAP (item.headers(“Date”)) then it is giving me Datetime format differently eg (Mon, 23 Dec 2019 12:32:40 -0800 (PST)) with my system datetime zone.
and when I am trying to convert it to date time it gives error that system did not recognize as datetime neither it is able to change timezoneifo . Date can be in any timezone so how can i easily convert it to this datetime to my system datetime zone(like PST, CST,UTC, GMT etc). Do i need to figure out every timezone and create criteria or any easy way?
Please help.
I know in outlook activity there is filter where we can set this criteria easily.

1 Like


if possible can i see the expression used to convert the date

I am using Convert.ToDateTime(item.Headers(“Date”))

Use this:

Datetime.parseexact(item.headers("Date").ToString,"ddd, d MMM yyyy hh:mm:ss zzzz (UTC)",System.Globalization.CultureInfo.InvariantCulture)

@bcorrea @PragmaticProgrammer
I did same but still saying system did not recognize valid datetime
Can you help

ok, so no luck for you, you need to do manual parse of that string and after a datetime.parseexact…

I am afraid still showing error system format exception. Also i need to change this date time zone equivalent to my timezone…so do i need to put condition for recognizing each timezone?

yes, maybe you will need real advanced stuff if you really need to parse this:

Thanks @bcorrea for your reply.
fetch item.headers(“Date”) then getting it convert that is very lengthy…I found out there is also created at: datetime in show original .which fulfill my criteria. I do not know how to fetch that date can you help if i can able to fetch that text thing would be pretty easy. Thanks again))

Where is that field present?

when you see show original by clicking right corner button contain 3 dots there you would find field


yes, but that is using the web browser right?

yes can we get that date field(Created at) in UI path somehow?
where we can put like in outlook
[ReceivedTime] > ’ " + Now.AddDays(-1).ToString(“MM/dd/yyyy”) + " ’ AND [ReceivedTime] <= ’ " + Now.Date.ToString(“MM/dd/yyyy”) + " ’ “).

imap does not have filters, but are you saying all this time you dont need the time?

1 Like

I need both date and time , i was just trying to find out if we can convert timezone it to our system time zone then it looks tedious work…
so i am figuring out to fetch datetime by (created at) anyhow?
let me know if we can work out by fetching datetime though (created at) in uipath

again Thanks for replying .