How can we list email threads with their subject and message count?

Will Overton 0 Reputation points
2024-10-10T15:01:21.1833333+00:00

We are building an email client and are want to have a threaded view of emails like in outlook for the user.

Currently we can list messages and get their conversationId. But we can not be certain we have every message in that thread. We would like to be able to provide a list of threads with their participants, subject, unread/read, message count, snippet from most recent message etc.

Ideally there would be some kind of https://graph.microsoft.com/v1.0/me/mailFolders('inbox')/threads
function but it doesnt seem to exist. We have found docs about listing "conversations" but they all require a group id etc which is not knowable.

How can we list threads using the Microsoft graph API?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,037 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Yakun Huang-MSFT 4,800 Reputation points Microsoft Vendor
    2024-10-11T06:12:58.04+00:00

    Hello Will Overton,

    Thank you for reaching out to Microsoft Support!

    Through lookup, the Graph API's List threads endpoint can List threads, which needs to provide groupID. You can get groupID by listing all the groups through the List groups endpoint with the following request:

    GET https://graph.microsoft.com/v1.0/groups
    

    The /me/mailFolders('inbox')/threads requests you need are not available.

    Hope this helps.

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

    0 comments No comments

  2. Hitesh Pachipulusu - MSFT 2,145 Reputation points Microsoft Vendor
    2024-10-11T06:20:35.84+00:00

    Hello Will Overton,

    Thank you for reaching out to Microsoft Support!

    It sounds like you're looking for a way to list email threads in a user's inbox using the Microsoft Graph API, similar to how Outlook displays them. While there isn't a direct endpoint like https://graph.microsoft.com/v1.0/me/mailFolders('inbox')/threads, you can achieve this by leveraging the conversations and messages endpoints.

    Here’s a step-by-step approach to achieve your goal:

    1. List Conversations: Use the endpoint to list conversations in the inbox:
         GET https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages
      
      This will give you a list of conversations, each with a unique conversationId.
    2. Get Messages in a Conversation: For each conversation, you can list the messages using:
         GET https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq '{conversationId}'
      
      This will return all messages in the specified conversation.
    3. Aggregate Thread Information:
      • Participants: Extract unique senders from the messages.
      • Subject: Use the subject of the first message or the most recent message.
      • Unread/Read Status: Check the isRead property of each message.
      • Message Count: Count the number of messages in the conversation.
      • Snippet: Use the preview text or the first few lines of the most recent message.

    Then, process the response to gather the required details. This approach should help you list and display email threads with the necessary details.

    Hope this helps.

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


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.