Get Exchange Mail Messages Filter Expression

HI,

I’m having difficulty using the filter expression of the Get Exchange Mail activity, I’m trying to use a date filter to retrieve the messages older than 60 days and if I write “received: <=10/25/2021” directly in the filter field I get the expected result but if I write “”“received: <=”+DateTime.Now.AddDays(-30).ToShortDateString+"""" I dind’t get any message, the same happens if I create a string with the result of this expression and write it in the filter field

The problem is with my expression that doesn’t fill the field requirements?

I found a topic with other expression similar to mine and tried but it gives no messages, so I don´t know what I’m doing wrong here.

The similar expression I found was “[ReceivedTime]>=’”+DateTime.Now.ToShortDateString+"’".

not sure if you tried this
put this quoted expression in a variable first and then pass it as a string in that filter expression field of the activity
Debug and see the value before the get exchange email activity, then check if that is working fine.

Hello

You have probably considered this idea already but if the filter is working reliably (and as per the documentation) it might be best to use that.

If it was me, I would use a couple assign activities to build the filter expression dynamically.

Like this:

  1. Assign a string variable to be “SixtyDaysAgo”
    image
  2. Then simply add this to a variable called “FilterToInsert”
    image

Result - Write Line for “FilterToInsert”:
image

Hopefully this helps :blush:

Cheers

@rahulsharma @Steven_McKeering Both should work but for some reason they don´t. Using the Write Line I can see that the value of the String is exactly as it should but the Get Exchange Mail activity whit a String or with a expression doesn’t shown any result but if I write the value of the String directly on the Get Exchange Mail activity it shows correctly the mails older than 30 days.

I can´t understand why. At the moment I’m using an workaround to filter the result of the Get Exchange Mail activity.

With the Get Exchange Mail activity without any kind of filter I get all the mails after that I just use this expression ltNewEmails.Where(Function(mail) mail.DateAsDateTime.ToShortDateString<DateTime.Now.AddDays(-60).ToShortDateString).ToList in a Assign to filter the mails.

It’s working and doesn’t have negative impact in the performance but since the Get Exchange Mail activity has the option to apply a filter I would like to know how to use it because maybe I’m the only with this issue meaning that the mistake is on what I’m writing on the field and not with the activity itself.

I am glad you have a workaround :blush:

Do you have “OnlyUnreadMessages” deselected?

If you are still persisting - maybe share a screenshot of the properties to see if @rahulsharma or someone else can see see if you are missing anything.

I don’t have any option select, only using the FilterExpression field.

image