Add filter in grapg api

abhishek appu 41 Reputation points
2022-12-07T17:29:27.727+00:00

This the code for read the mailbox using graphapi.Here i filtered the mailbox by unreadmail.But i need to filter mail subject by "notify service to lookup new mail" and sender by jon@jaswant .in.((only need to read these condition satisfy unreadmails))How can i add these two filters here?268257-filter.png

Attached the code here.

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management
The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 6,086 Reputation points
    2022-12-07T21:34:29.937+00:00

    Hi @abhishek appu

    To get the mail with the above filters use the below code.

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
        var messages = await graphClient.Users[shivam1@m365x******.onmicrosoft.com].MailFolders["Inbox"].Messages  
            .Request()  
            .Filter("from/emailAddress/address eq 'DiegoS@M365x*******.OnMicrosoft.com' and subject eq 'Notify service to lookup new mail'")  
            .GetAsync();  
    

    As you can see, I am able to get the desired result using this same graph API.
    268382-mail4.png

    Hope this helps.

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

    1 person found this answer helpful.

Your answer

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