How to filter out emails from a certain domain

Akshay Dalal 0 Reputation points Microsoft Employee
2025-02-07T10:36:48.3666667+00:00

How do I filter out emails from a certain domain ?

/me/messages?$filter=not(contains(from/emailAddress/address,'xyz.com')) doesn't return right results &
/me/messages?$filter=endswith(from/emailAddress/address,'xyz.com') is not supported

even

/me/messages?$search="NOT from:@xyz.com" also doesn't return right set of results.

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

1 answer

Sort by: Most helpful
  1. Vasil Michev 113.4K Reputation points MVP
    2025-02-07T17:30:42.5466667+00:00

    The first one works fine here, what kind of incorrect results are you seeing? Keep in mind that this query will not only return messages from all other domains, but all the items without properly formatted From address too. RSS items, items sent via Power Automate, NDRs, and so on, will all match the clause.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.