How to send message in a thread using microsoft graph API?

2.1k views Asked by At

I'm building a tool in which I need to send more than 2 messages in the same thread (the message have identical subject & recipients) using Microsoft Graph API with some interval of days between them.

The problem is that I cannot send a message in the same thread using the API, even though the subject & recipients are same, Outlook displays them as different threads (but on the recipients' side (Gmail side) - they belong to same thread).

I tried using conversationId (which I got in the first message) in the second message but they still ended up showing in different threads.

Is there any way in I can send messages in the same thread?

2

There are 2 answers

4
Keen Jin On BEST ANSWER

According to your description, I assume you want to use the https://graph.microsoft.com/v1.0/groups/{id}/threads endpoint to send more than 2 messages in the same thread. Refer to this document,

A new conversation, conversation thread, and post are created in the group. Use reply thread or reply post to further post to that thread.

So we can use the replay endpoint to send message in the same thread.

0
Oleksandr Bondar On

To send emails in one thread you should use createReply method where you provide messageId of a previously sent message.

The tricky part is that after you sent a message with send or sendMail API methods, you do not have access to messageId. Even if you create a message via create method, messageId will be different after sending it.

So the solution is to send the message and find it in 'Sent Items' folder to retreive messageId. I am doing this based on time, subject and receiver. There is also useful param $top.

With correct messageId you'll be able to create reply and send it in the same thread.