O365 Get Mail, Odata filter

I am about to create a processes that is to be used to verify the work of another process that recently was put into production.

One part of this new process is to check if an email has been sent to a certain address. To do this I am using the O365 Get mail activity with an odata filter expression.

As far as I can understand the following expression should do the trick:
“$filter=toRecipients/any(t:t/emailAddress/address eq ‘xxx.yyy@zzz.com’)”

But I get this error message:
Message: Code: BadRequest
Message: Invalid filter clause: ‘)’ or operator expected at position 55 in ‘(receivedDateTime ge 1900-01-01T00:00:00Z) and ($filter=toRecipients/any(t:t/emailAddress/address eq ‘xxx.yyy@zzz.com’))’.

I am by no means an expert on odata filters, but to me it seems like the get mail activity add that first part that checks received date time and then put my expression in a parenthesis as a second part. What I understand you can not have the filter “statement” inside a parenthesis and this can be the cause of the error.

Any help is appreciated
///Jerry

Hi @jerry.lundgren1,

Please try point 9 mentioned in below thread. I believe in your case, it will be ‘to’ instead of ‘from’.

Regards
Sonali

Hey @jerry.lundgren1
You should remove the $filter= part from your filter string and only include the actual logical condition

toRecipients/any(t:t/emailAddress/address eq ‘xxx.yyy@zzz.com’)
Make sure:

You use single quotes ’ (not curly quotes like ‘ or ’).

You don’t wrap the entire thing in another $filter=, as UiPath handles that.

So the full final filter applied by UiPath would become something like:

$filter=(receivedDateTime ge 1900-01-01T00:00:00Z) and (toRecipients/any(t:t/emailAddress/address eq ‘xxx.yyy@zzz.com’))
Which is now a valid OData filter.

cheers

Thank you for clarifying how to format these odata filter expressions. But I just can’t get this to work and i have a suspicion that the “toRecipients” property is not compatible with filter expressions. While googling I have seen some comments here and there that it can be that way.

I can get other variants of odata filter to function as I want, just not with “toRecipients”.

Best regards
///Jerry

Thanks for your suggestion, I tried some variations of that but could not get any of them to work.

Best regards
///Jerry

Hey @jerry.lundgren1 This isn’t a UiPath issue — it’s a limitation of Microsoft Graph API, even in raw HTTP requests.
What Does Work in $filter

You can use these in your filter:

Field Supported?
from/emailAddress/address :white_check_mark: Yes
subject :white_check_mark: Yes
receivedDateTime :white_check_mark: Yes
isRead :white_check_mark: Yes
toRecipients :cross_mark: No
ccRecipients :cross_mark: No
attachments :cross_mark: No
1 Like

Even if it did not solve my problem I must say that this is the solution. I just have to do it another way.

Best regards
///Jerry

1 Like