Conversion from string (item.headers("date")) to type 'Date' is not valid

Hi friends

Please help me with this issue. This is my case

I need to get a mails list from gmail, I am using “Get IMAP Mail Messages”, from this list of mails I need to catch every mails sended yesterday, for that I am using for each and for every item I am getting the sentence item.Headers(“date”) for know the receive’s date. In other variable type datetime I am catching the actual date “NOW”.

As item.Headers(“date”) is string, I need to convert to date for comparation with now date, here is my issue because the mails have different type of date, for example, some mails come with date like:

“Sat, 25 Jan 2020 03:45:30 -0500”-> this apply Cdate(item.Headers(“date”)) and convert well

“24 Apr 2020 10:42:42 -0500” → this apply Cdate(item.Headers(“date”)) and convert well

but whith next date appear a error “Wed, 06 Nov 2019 16:23:23 +0000 (UTC)” appear this error: Assign: Conversion from string "Wed, 06 Nov 2019 16:23:23 +0000 " to type ‘Date’ is not valid.

I have tried to convert for many way but I can´t to goal

I hope you can help me pelase and I am sorry for my english,

I have read these topic:

but until now nobody have answer for that.

Hey Carlos, change your assign to this:

DateTime.ParseExact(fechacorreoaux1,“ddd, dd MMM yyyy H:mm:ss zzzz (UTC)”,system.Globalization.CultureInfo.InvariantCulture)

and it will work like a charm :slight_smile:

Hi Anders

Thanks very much for you answer, I have tried like you tell me but the issue persist:

Hey Carlos, can you set your input to “Wed, 06 Nov 2019 16:23:23 +0000 (UTC)” and see if it still gives an exception? Or check if it still that date that gives you an error. If not, then your input data is changing and we gotta solve for that.

Hey Carlos, I’ve attached the code and it works perfectly from my side.
Main.xaml (4.5 KB)

1 Like

AndersJensen
thanks you man, I was commited a mistake, I was using: " " and you ” ” in the sentense
mistake

:+1: :+1: :handshake:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.