1

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?

shivtej
  • 633
  • 9
  • 18
  • how did you retrieve messageid/conversationid after you sent the message using /microsoft.graph.sendmail endpoint. As it doesnt return any response , i was curious how did you retrieve them – zee Jun 16 '19 at 15:26
  • @zee This GitHub issue posted describes a way to do this by adding a custom identifier and then querying for it: https://github.com/microsoftgraph/microsoft-graph-docs/issues/3766 – David Garza Nov 22 '19 at 13:57

2 Answers2

1

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.

0

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.

Keen Jin
  • 1,060
  • 1
  • 6
  • 8
  • In my use-case, creating groups is not feasible and it actually voids one of the requirement. – shivtej Nov 12 '18 at 14:42
  • `https://graph.microsoft.com/v1.0/me/microsoft.graph.sendmail` for sending mail. I thought if I add conversation-id or thread-id in the subsequent request then the mails will go in the same thread. – shivtej Nov 13 '18 at 10:26
  • We can use the [replay endpoint](https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/message_reply) to send message in the same thread – Keen Jin Nov 14 '18 at 01:34
  • Actually, I did look up this API but I want to send some attachments too which is not possible according to documents. – shivtej Nov 14 '18 at 14:17