Check whether if a particular email has not been replied in Microsoft graph API

cool atta 1 Reputation point
2022-03-15T12:18:09.007+00:00

Hi folks;
I am working on a problem in which I could find out that if a particular email or conversion has been replied using Microsoft graph API. I have tried different logics like create time, sent time, received time but none worked for me. Please guide, your help would be highly appreciated.

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

1 answer

Sort by: Most helpful
  1. Glen Scales 4,431 Reputation points
    2022-03-15T23:34:55.393+00:00

    There are a number of ways to do that, if you want to find the response to a message the easiest way should be to take the InternetMessageId from the original email in the Inbox eg

    GraphServiceClient graphServiceClient = new GraphServiceClient(credentials);  
      
    var Messages = graphServiceClient.Users["user@domain.com"].MailFolders["Inbox"].Messages.Request().Select("Subject,InternetMessageId").Top(1).GetAsync().GetAwaiter().GetResult();  
    Console.WriteLine(Messages[0].InternetMessageId);  
    

    and then you can search for any messages in the SentItems folder that are In-Reply-to that message using the In-Reply-To headers extended property

        String filterval = $"singleValueExtendedProperties/Any(ep: ep/id eq 'String 0x1042' and ep/value eq '{Messages[0].InternetMessageId}')";  
          
          
        var Replies = graphServiceClient.Users["gscales@datarumble.com"].MailFolders["SentItems"].Messages.Request()  
            .Filter(filterval).GetAsync().GetAwaiter().GetResult();  
          
        Console.WriteLine(Replies.Count);  
    

    Another approach can be to use the LastVerbExecuted extended property https://learn.microsoft.com/en-us/answers/questions/373854/identify-forward-and-reply-emails-using-graph-api.html