3

I would like to use the Outlook REST API to display the messages in a mail folder and group messages by conversations, like you have in any modern webmail.

For example with inbox, I would request using a first query such as <mailuri>/inbox/messages?$select=ConversationId (by default it is reverse chronological order)

It is not sufficient to group this request results by ConversationId because some emails may not be in inbox (think of sentmails) or they may be paginated and not returned in the first page.

Consequently, for each distinct ConversationId I need to perform another REST request, for retrieving participants or simply counting the emails in the conversation. I may use the new batch request to do this.

There are a lot of requests involved. Is there a better solution ?

Benoit Patra
  • 4,355
  • 5
  • 30
  • 53
  • This topic as lead to a dedicated UserVoice feature request, consider upvoting https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/18765490-be-able-to-fetch-mails-by-conversations-in-folde – Benoit Patra Mar 29 '17 at 17:22

2 Answers2

4

As you've probably realized the REST API doesn't directly provide a way to work with conversations as an entity. This is something that we have on our roadmap to improve.

With the current state of the API what you're describing is basically the right approach. You could possibly defer the second request to "fill in" a conversation until the user selects it.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Has there been any progress around having conversations being a part of the API? We noticed Conversations and ConversationThreads added as a part of the new groups API, but what about inbox, drafts and other non-group mail items? – wintondeshong Apr 28 '19 at 16:54
  • any update on this is there any api to get messages grouped by conversations? – Cycl0n3 May 16 '23 at 07:26
3

You can actually use this endpoint to cover both inbox and sentitems

https://outlook.office.com/api/v2.0/me/messages/?$select=ConversationId & $filter=ConversationId eq '${params.conversationId}'
Dan Perry
  • 123
  • 6