How to read mail backward?

If I key input dialog = 3
Today date = 21/01/2021
I want to read email between date 19/01/2021 - 21/01/2021

Please guide me about it.

Let’s say u have a list of mails in mail_list variable.
inputdays is the no of by which u want to move date backward

then u use below query to.filter it

mail_list.Where(Function (mail) DateTime.ParseExact(mail.Headers(“Date”),“MM/dd/yyyy HH:mm:ss”)>Now.AddDays(-inputdays) And DateTime.ParseExact(mail.Headers(“Date”),“MM/dd/yyyy HH:mm:ss”)<Now)

Try this

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

2 Likes

@NIVED_NAMBIAR error :
image

Can u show how the date is looking like by mail.Headers(“Date”)

@NIVED_NAMBIAR

image

Hi @fairymemay

I had corrected my response

Please check the code

Hi @fairymemay

Try this in filter property of get outlook mail message activity
“[ReceivedTime] >= '”+Now.AddDays(input).Date.ToString+"’ AND [ReceivedTime] <= ‘"+Now().Date.ToString+"’"

where input is the number of days needed to be subtracted

Regards

Nived N

Happy Automation

Hi @fairymemay

Please check the updated workflow
test read mail.xaml (6.5 KB)

I had added annotations so that u can easily understand.

Regards

Nived N
Happy Automation

@NIVED_NAMBIAR I key inputday = -1
I found error as below :

image

@NIVED_NAMBIAR How to solve it?

Hi @fairymemay sorry for delayed response ,

Kindly check this

test read mail.xaml (7.2 KB)

Hope it helps you

Regards

Nived N

Happy Automation

1 Like

did it worked?