3

Is it possible to query for the first, or all emails from a particular conversation id using the Microsoft Graph? If not, how about with the classic Exchange API?

Scenario: I am creating an application where I am interested in tracking the user who started an email thread, and the content of their initial message.

When querying for mail using the Microsoft Graph, I can get back an id unique to that email, and a conversationId unique to that email thread. The body returns the full email thread so far, but it is none trivial to parse (are there tips to parsing the returned HTML?), and may not always be accurate if people are adjusting the mail that gets sent back and forth.

Maybe the solution here is to parse the full body HTML, but I have not seen any documentation on best practices here. Any tips?

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69

1 Answers1

6

To get all mails with same conversationId, you can use

GET https://graph.microsoft.com/v1.0/me/messages?$filter= conversationId eq 'yourConversationId'

Microsoft Graph is using OData. So you can use query parameters to customize responses.

For how to use query, please check this document.

Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267
  • Note that you should be logged (click on the button "Sign in with Microsoft") to be able to actually fetch your related mails. Else, the API will return an empty array as result. Might be obivous btw. – Anwar Dec 15 '17 at 13:46
  • i got Invalid filter clause errors while executing this – Syamlal Dec 18 '19 at 07:10
  • 1
    2020 and I still got invalid filter clause errors like above – Tai Ly Jun 01 '20 at 11:01
  • If you're using the graph explorer you need to URL encode the conversationID. For example if it ends with a trailing `=` it becomes `%3D`. Confirmed just now that this works. – jkamdjou Oct 02 '20 at 15:01