How can I filter emails by the recipient email address in Microsoft Graph API?

Nana Blay Eku-Kintoh 0 Reputation points
2024-06-26T14:13:56.0066667+00:00

I am working with a mailbox that has emails of different recipients forwarded to it. I am trying to filter messages by the recipient email address using the any filter, but I get the following error:

Client Error: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/messages?%24top=25&%24filter=toRecipients%2FemailAddress%2Faddress%2Fany%28a%3Aa%2FemailAddress+eq+%27uspto%40borris.law%27%29+and+receivedDateTime+gt+2024-06-11T00%3A00%3A00-04%3A00 | Error Message: Invalid filter clause: The parent value for a property access of a property 'emailAddress' is not a single value. Property access can only be applied to a single value. | Error Code:

How can I modify the filter to resolve this issue?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,270 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 1,950 Reputation points Microsoft Vendor
    2024-06-27T02:22:44.08+00:00

    Hi @Nana Blay Eku-Kintoh

    You cannot filter by toRecipients email address because these properties do not support filtering.

    You can use it in search, tested, this works very well, the test results are as follows:

    Screenshot 2024-06-27 102003

    See this link for more usage:

    https://video2.skills-academy.com/en-us/graph/search-query-parameter?tabs=http

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.