Problem with datetime.ParseExact() - Portugal

Hello guys!! good morning!

I’m struggling with ParseExact right now and I can’t resolve it.



"DateTime.ParseExact(item.Headers(“Date”).ToString, “MM/dd/yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyyMMdd_HHmmss”)

The main idea is to download attachments from the emails and place them into folder renamed with the current date and time


I’m from Portugal, any idea how to solve this?

Thank you in advance.

Patterns are not matching
Please provide us a sample of the date string which is sent to ParseExact or is it this Mon, 21 Jun… String


The format you mentioned should match the actual value(item.Headers(“Date”).Tostring)

I changed that already, doesn’t work :confused:

"DateTime.ParseExact(item.Headers(“Date”).ToString, “dd/MM/yyyy HH:mm:ss”,

Hi ,

Not that !!!

The string you have “Mon, 21 Jun 2021 09:55:22 +0100” is not in the format that you mentioned to parse(“MM/dd/yyyy HH:mm:ss”,). The formats of those should match.

Do the below ,

From the string “Mon, 21 Jun 2021 09:55:22 +0100” try to extract “21 Jun 2021 09:55:22” using String Manipulations and then use parser with format dd MMM yyyy HH:mm:ss

Hope it works !!!

Hello, yes it is Mon, 21 Jun … you have two screenshots up there buddy. One from message box and the other from a write line :slight_smile:

Hello, do you have any examples?. So I can read and learn.
That can be very simple to do, but I never did it before. And it may be tricky :stuck_out_tongue:

it was asked as your used format string was not matching the input format. Have a look below:


Hi there!
That’s worked for me. Thank you

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