You can Microsoft Search API for filtering emails. https://docs.microsoft.com/en-us/graph/search-concept-messages