Ui path automation Extract date and time from outlook email

Hi do you happen to know how to extract date from outlook email using this process below?
Could someone help me out?

If Date < 7th of current month
Start date = 1st of previous month
End date = 20th of current month

Else If Date > 7th of current month
Start date = 1st of current month
End date = Last day of current month

Can you elaborate? Is this from body or header?

Regards,



This is what I did for the date and time. As you can see I this is hardcoded. Now I need it to be extract from the email.

My question is which date we should extract. Is it receivedDate in Mailheader or described in mail body?
Can you share screenshot of it if possible?

Regards,

@jnarthan.g

Do you want to extract the emails between those start and end dates?

If so you can use the following filter

"[Received] >= '" + variablecontainingstartdate + " 00:00AM' AND [Received] < '"+ variablecontainingenddate + " 00:00AM'"

Those variables should contain only dates…if you want to include time then remove 00:00AM as well

Cheers

If you need to extract it from mail header, the following sample will help you.

Sample20230310-3Lv2.zip (3.1 KB)

Regards,

Hi there.

My apologies for the late reply.

It’s actually described in mail body.

Could you help me out with this ya ?
I really do could use some ideas and help.

Thanks and regards.

Hi,

Can you share sample of the mail body? And also if there is fixed string, can you share it?
In general, we can extract the date using Regex etc.

Regards,


As you can see the highlighted one is my own outlook mail.
If I am not wrong this is the mail body right ?

Regards.

Can you kindly show how can it be done.

Regards,

HI,

It’s date in header. Can you try as the following?

If you need date string of same format with the above, the following will work

CDate(currentItem.Headers("Date")).ToString("ddd d/M/yyyy h:m tt")

Regards,

Could you kindly send me this file for me to refer?
It would be more convenient to refer with the file.

Regards,

Hi,

Here you are.

Main.xaml (6.9 KB)

Regards,

Thanks will get back to you on this matter.

And also could you help me out with this.

Could you share any ideas where I can extract few things from email. Meaning from the mail body.
The list that need to be extract from mail body are as below :
Subject
Received Date
Destination
Booking number
ETA
Identifier
Number of container and size

Regards,

HI,

As topic title should match its content (because it will help those who have same issue), it’s better to discuss the above matter in the following topic you already posted.

Regards,

Oh didn’t know this. First time using this forum.

Alright thanks,
Regards,

However will this work with the screenshot I have send about the date and time

HI,

The above Main.xaml outputs date in each mail as the following. Give it a try.

img20230314-1

Regards,


I tried doing this but it’s getting some error.
Note: This is an old version 2020 ya.

Thank you.

Regards,

HI,

Which type is mails variable? It should be List<MailMessage> (From GetOutlookMailMessage)
And please set MailMessage at TypeArgument in ForEach.

Regards,