Get Email Query Categories

I am attempting to retrieve emails using various search parameters, including category. However, I have been unsuccessful in getting any of the query combinations below to work properly. Only one of them executes without throwing a bad request error, but it returns 0 results, which is incorrect (as shown in the screenshot). This issue persists regardless of the number of categories attached to each email. Ideally, I would like to use a longer search parameter that includes subject, sender, and multiple categories.

Here are the queries I have tried so far:

“contains(subject, ‘Test Email, Azure token’) and contains(categories, ‘BOT Pending’)”

“contains(subject, ‘Test Email, Azure token’) categories eq ‘BOT Pending’”

“contains(subject, ‘Test Email, Azure token’) and categories eq ‘BOT Pending’”

“contains(subject, ‘Test Email, Azure token’) and categories(c:c eq ‘BOT Pending’)”

“contains(subject, ‘Test Email, Azure token’) and categories/any(c:c eq ‘BOT Pending’)”

only the last one(bolded) worked but with zero results, I searched the inbox, and here is the screen shot of the inbox


i have working simple queries that search from and subject to test the activity works, which works so I know its the query

Here are my dependencies, I do use one of the latest studio with a windows project not legacy.


Main Questions

  1. Please assist me in constructing the correct query to retrieve emails based on category.
  2. I need to retrieve emails by searching for multiple categories, such as “Blue Category” and “BOT Pending,” similar to what is shown in my screenshot.
  3. I would like to retrieve emails by searching for multiple categories, as well as specifying a specific subject and sender email address. I have successfully implemented the search for subject and sender email separately, but not in combination with the categories.


Can you please remove filters and retrieve an email with categories and show the structure please from locals panel so that it eould be easy to understand structure and provide you with a query

And /any is working because categories come as jarray and for jarray only any and all works…we need to know the internal structure as well


For some reason, with the latest 365 update (2.1.1) or the studio, I am unable to view the array structure on the side panel as we used to. However, everything is functioning correctly. Here is how I typically retrieve the categories after looping (in this case, just the first index):


here is what I see in loop current item in the watch. You can see the structure I suppose



As per the structure ideally the formay you highlighted in bold should be getting the email…check if you have marked get only unread or so…

If not the only other wany would be user subject and sender in filter and after retrieving use linq to get the required category emails

outmessages = Outmesaages.Where(function(x) x.Categories.contains("BOT Pending"))

This will filter the retrieved emails on category further


Thanks, ya I can retrieve all mail and filter, but I was trying to look for a way to do that in the search query itself

this is latest doc , I tried as it states too with no luck - * “categories/any(a:a+eq+‘Red+category’)”


Plus or having space is same…but yes….for some reason we already observed few odata queries are not working on office365…and as per structure the query is proper

That is the reason gave a work around…let me check if I can get some sp access if yes will check more tests on my side…


1 Like

I believe you have to use categories/any not just categories. So…

categories/any(a:a eq ‘BOT Pending’)


Mr P With a win again,

So this is the only format that worked

"categories/any(a:a eq 'BOT Pending')"

Thought I tried the same combo with “+” it threw bad request

Like I said in the question this combo also worked without error but no result

categories/any(c:c eq ‘BOT Pending’)

So putting c:c was the issue for me, its actually a:a . Atleast in my case. what do they stand for?

Not really sure but I saw one explanation that assumed it’s some sort of variable and there shouldn’t be a difference between a:a and c:c

I think it’s some sort of notation like a function where “a:a eq ‘something’” returns the results of “a eq ‘something’” into a. Must have something to do with categories being an array.

1 Like

Does a:a still work if the category you filter for is the second category on the email?

BOT Pending was already the second category, so it worked, I tried adding another one like orange, no issues. Seems to works regardless of the index


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.