How to use query for Office 365 Get Mail activity?

I am trying to retrieve email from Office 365 outlook.
I have already got it to retrieve all emails in the specified folder, without any problem. Now, I want to use the filter query so that I will only retrieve the following emails:

  1. emails whose subject line contains “examplePhraseA” or “examplePhraseB”.

  2. emails whose subject line starts with “examplePhraseC”

  3. emails whose email body contains “examplePhraseD”

  4. emails whose email body starts with “examplePhraseE”

I checked the URL provided, and it seems like I could use $filter=startswith( but I am not sure exactly how.
Can someone please help me out?

@tomato25 -
in get outlook mail message → properties → filter option

"@SQL=urn:schemas:httpmail:subject LIKE '%Your Item%'"
OR
"@SQL=""http://schemas.microsoft.com/mapi/proptag/0x1000001E"" like '%Your Item%'"

pls refer below link for multiple filter options -

For Office 365 Activities use only filter in graph API query parameters

Example:
https://graph.microsoft.com/v1.0/me/messages?$filter=subject eq ‘let’‘s meet for lunch?’

In UiPath just use it as:
“subject eq ‘let’‘s meet for lunch?’”

For anyone wondering how to search by body text, use this: contains(body/content,‘valueToSearchFor’)

Hello,

I need the same but I need something like the following “contains(subject,‘P123’)” but I need another contains inside the filter and is not working.

e.g. My Subject: Filtering subject by the first letter ending with email@example.com

I would like to filter If contains the first word and also If contains the email in the subject. Is this can be done in the filter of Get Mail activity office 365?

Hi,

I want to filter using categories but i am not able to find correct filter

I am using “contains(Categories,‘xxxx’)”

Use this to filter out the From email address, Subject and attachment (True or False):

(from/emailAddress/address ne ‘FromEmailAddress’) and (startswith(subject, ‘YourSubjectFilter’)) and (hasAttachments eq false/true)

Thanks for response @Debasis_Nayak , I was looking for “Categories” Not for this.
As my requirement itself is perticular Category

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: Use the $filter query parameter to filter a collection of objects - Microsoft Graph | Microsoft Learn
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.

All documentation is for Subject, From, and Category. I need other properties such as attachment content, received date, body content, etc. Is there a place where all properties syntax is found?

2 Likes

In case it helps, this is the Message model reference for the Graph API, with all the properties that you can include in the query predicate (subject, body, from, receivedDateTime, etc):

message resource type - Microsoft Graph v1.0 | Microsoft Learn

Also, this reference for the supported operators in ODATA queries could be useful:

Use the filter query parameter to filter a collection of objects - Microsoft Graph | Microsoft Learn

I have not yet found how to filter by the date of receipt too.