How to extract received date from email and assign to variable

Hi,

Can anyone share me how to extract received date from email.
I did it but it’s basically manually key in like hard coded.
Anyone can teach me dynamically ?
How to extract the received date from email to assign a variable.

Please find the below image file for your reference.
This the hard coded received date I did.
Please help me out.


Hi @jnarthan.g
Check this
image

Hope this helps.

Hi @jnarthan.g

How about the following?
image

currentItem.Headers("Date")

Regards!

Hi @jnarthan.g

Do you asking to extract mail received date or some date mentioned in the mail body.

If you want to extract Mail Received Date use the below:

Mail_Received_Date(var type system.DateTime) = Convert.ToDateTime(yourMailvar.Headers(“Date”),Globalization.CultureInfo.InvariantCulture)

If you want to extract some date mentioned in mail body use this:

Step 1: MailBody(var type string) = yourMailvar.Headers(“PlainText”).ToString
Step 2: MailBodyDate (var type string) = System.Text.RegularExpressions.Regex.Matches(MailBody,“\d{1,2}\W\d{1,2}\W\d{2,4}”)(0).Value

Cheers

Hi,

It’s working as you told.
Thank you for your help.
But need one more favor.
How to change the format we want. For example the format I want is 16/3/2023 but it came out 16 march 2023.
Have any idea ?

Regards,

Hi @jnarthan.g

Try this
image

DateTime.ParseExact(inputDate,“dd MMMM yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Hope this helps