GetIMAPMailMessage FilterExpression Subject Body

The GetIMAPMailMessage FilterExpression is by default set to ALL (to AND all the Criteria) but it does not appear to work if the Criteria includes SUBJECT and BODY, or SUBJECT and TEXT. It returns no matching email.

Examples of Working filters:
“FROM email.com BODY Citrix”
“FROM email.com SUBJECT 41” is same as: “ALL (FROM email.com) (SUBJECT 41)”

Examples that do NOT work:
“FROM email.com SUBJECT 41 BODY Citrix”
“SUBJECT 41 BODY Citrix”
“SUBJECT 41 TEXT Citrix”

I actually need to filter based on matching 3 criteria like:
“FROM email.com SUBJECT 41 BODY Citrix”
Adding the additional criteria does not matter, it is the Subject that doesn’t play well with BODY or TEXT

1 Like

Hi @FL.Duck,

Can you please elaborate a more on the issue, if I am getting right you require 3 filters to be applied on?? Correct.

Thanks

Yes I require at least 3 possibly 4. (FROM, SUBJECT, BODY (or TEXT), and possibly a second SUBJECT).
The fact that I can observe the issue with SUBJECT and either BODY or TEXT appears to be the root issue. The quantity of filters should not matter.

1 Like

Hi @FL.Duck,

Could you try inserting SUBJECT, BODY and TEXT values between TWO double quotes?

According to the documentation, it’s how we are supposed to do

If this solves your problem, kindly mark this post as solution to close this topic

If you need extra help and/or have any question, please let me know :slight_smile:

Thanks!

I stripped out all the quotes and made each a single word rather than a phrase. Same results using "SUBJECT ““41"” BODY ““Citrix””” Quotes are only required if the match contains spaces

1 Like

@FL.Duck

That’s strange

I’ve just tested here the following expression:

"SUBJECT ""Report Delivery"" FROM email@email.com BODY ""Date Run"""

It worked as expected.

Just to make sure… Have you checked OnlyUnreadMessages?

image

Perhaps, you have an email with these criterias but it is marked as read and you set to get only unread ones.

Had to remove images…

None of the email is read in that folder… unchecking has no change.
If I do NOT put SUBJECT and BODY in filter it works fine. any combination of those returns 0

I have UiPath Support engaged on this now.

1 Like

@FL.Duck,

Have you informed the correct folder name?

image

Inbox was just an example

If this is not the reason, my last advice would be to verify that the account configured in the activity is exactly the same as the one you verified the emails.

Yes, it’s the Inbox. The only change I make is the filter. With SUBJECT and BODY nothing returned, with SUBJECT OR BODY I get all matching emails

1 Like

Got it @FL.Duck

Feel free to share the solution when you receive the response from UiPath Support and find out what’s causing this error.

Hola,

¿Conseguiste solucionarlo?

Tengo el mismo problema.

Gracias!

I never found a solution for this using IMAP.
We ultimately just started using UiPath.MicrosoftOffice365.Activities.Mail.GetMail

Here’s my notes on the filtering in this:
“categories/any(a:a+eq+‘Red+category’)”
“contains(subject, ‘ICE’)”
“ReceivedDateTime le 2021-07-23T23:01”

“subject eq ‘New Authentication Request’”

Studio 2022.4.3
After a lot of trial and error, a case with UiPath, and interesting searching we found the best documentation (For https://docs.uipath.com/activities/docs/office365-get-mail) for the query at: https://learn.microsoft.com/en-us/graph/filter-query-parameter#examples-using-the-filter-query-operator

• “subject eq ‘Office365 Quickstart’ and from/emailAddress/address eq ‘someone@company.com’”

O365 V1.11.1 works with both of the following:
“categories/any(a:a+eq+‘Red+category’)”
“contains(subject, ‘ICE’)”
But in V1.14.1 (and 1.16.1 prerelease) only the second works. The first one generates a BadRequest, Invalid filter clause.