How to use ReceivedDateTime filter in Graph client C#

SAC_535 36 Reputation points
2022-03-11T06:50:50.133+00:00

var message = await graphClient.Users["{user id}"].MailFolders.Inbox.Messages.Request.Filter($"ReceivedDateTime eq").GetAsync();

this call is not working

how to use ReceivedDateTime in filter query in GraphClient C# call

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

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 37,956 Reputation points
    2022-03-11T07:35:08.987+00:00

    Hi @SAC_535

    Suppose you want to get all emails received by a user between February 1, 2022 and February 2, 2022, then you can filter by the following sample:

     var filterString = $"ReceivedDateTime ge 2022-02-01 and receivedDateTime lt 2022-02-02";  
      
     await graphClient.Users["{user id}"].MailFolders.Inbox.Messages  
    .Request()  
    .Filter(filterString)  
    .GetAsync();  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.