Get email from previous day

I am trying to get email from previous day. I am current using this filter - “receivedDateTime eq ‘”+ now.AddDays(-1).Tostring +“’”

But Its giving me this error

image

image

Thanks in Advance

try this

"ReceivedDateTime ge "+now.AddDays(-1).Tostring+" and ReceivedDateTime lt "+now.Tostring

1 Like

Hi,

How about the following?

  "receivedDateTime ge "+ now.AddDays(-1).Tostring("yyyy-MM-dd") +" and receivedDateTime lt "+now.Tostring("yyyy-MM-dd")

Regards,

1 Like

It doesn’t seems to be working.

Email received time - [10/11/2022 22:39:35]

I tried - "receivedDateTime ge “+ now.AddDays(-1).Tostring(“MM/dd/yyyy hh:mm:ss”) +” and receivedDateTime lt "+now.Tostring(“MM/dd/yyyy hh:mm:ss”)

getting this error

image

Hi Jack,

It didn’t worked

It doesn’t seems to be working.

Email received time - [10/11/2022 22:39:35]

I tried - "receivedDateTime ge “+ now.AddDays(-1).Tostring(“MM/dd/yyyy hh:mm:ss”) +” and receivedDateTime lt "+now.Tostring(“MM/dd/yyyy hh:mm:ss”)

getting this error

image

Hi,

My expression is

"receivedDateTime ge "+ now.AddDays(-1).Tostring("yyyy-MM-dd") +" and receivedDateTime lt "+now.Tostring("yyyy-MM-dd")

Did you try this?

Regards,

ya but it’s not picking up any email

image

Hi,

The filter syntax seems correct because of no error.

How about the following?

"receivedDateTime ge "+ Today.AddDays(-1).Tostring("yyyy-MM-ddTHH:mm:ss") +" and receivedDateTime lt "+Today.Tostring("yyyy-MM-ddTHH:mm:ss")

Or try to change -1 to -7 ,for example, in AddDays if can get some mail?

Regards,

This worked by changing to -2 days.

The issue now is my outlook shows I recevied the email on -
image

But UiPath shows - [10/12/2022 15:18:35]

I think I need to find a way to filter out email from last day. Might loop through email list.

Hi,

It might be timezone matter. If we need to convert localtime to UTC, the following might work. Can you try this?

"receivedDateTime ge "+ System.TimeZoneInfo.ConvertTimeToUtc(Today.AddDays(-1)).Tostring("yyyy-MM-ddTHH:mm:ss") +" and receivedDateTime lt "+System.TimeZoneInfo.ConvertTimeToUtc(Today).Tostring("yyyy-MM-ddTHH:mm:ss")

Regards,

Hello @ravindar.singh

Please check the similar thread.

Thanks

The filter works but it’s still missing out on some email that recevied yesterday early in the morning( because of 10 hour issue)
. So I decided to use this - "receivedDateTime ge “+ now.AddDays(-2).Tostring(“yyyy-MM-dd”) +” and receivedDateTime lt "+now.Tostring(“yyyy-MM-dd”)

to get email from the last 2 days and then for each loop I added 10 hours to received date and use this If condition

image

Which giving the outcome I am after