How to query emails by recipient's email address?

Shaun Yang (Medalsoft) 0 Reputation points

I am using the Graph REST API. Below is my URL.'SentItems')/messages?$filter=sentDateTime ge 2024-04-27T16:00:00Z and sentDateTime le 2024-05-04T15:59:59Z and toRecipients/any(a:a/emailAddress/address eq '')"

I got error ErrorInvalidUrlQueryFilter, the message is The query filter contains one or more invalid nodes.

How can I fix this or is there any other way to achieve my goal?

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

1 answer

Sort by: Most helpful
  1. Saranya Madhu-MSFT 150 Reputation points Microsoft Vendor

    Hello @Shaun Yang (Medalsoft) ,

    Thanks for reaching Microsoft!

    I am able to replicate your issue. I would like to suggest a workaround. You can try using the $search query parameter with the Microsoft Graph API.

    For example, you can use the following query to filter by the "to" field:$search="to:{searchphrase}"

    Document reference:

    Hope this helps.

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