I have two gmail accounts I created a thread consisting of five messages and retreived them with gmail gapi at this page https://developers.google.com/gmail/api/v1/reference/users/threads/get.
This is what I got:
As you can see, the ids don't match, although they identify the exact same letters. Why this happens, and how can i get the unified id?
P.S. The real reason I am doing this is that I need to send a reply to a message with gmail API, but to do that, you need to know the id of the message that you reply to. And if I reply to the message with id that I have ( not the message id that the receiver has ), it just sends a 'new' message.
How can I send replies with Gmail API?
Thank you in advance.
As the docs say, if you're trying to send a reply and want the email to thread, make sure that:
Subject
headers matchReferences
andIn-Reply-To
headers follow the RFC 2822 standard.If you want to do this yourself, you could get the
Subject
,References
andMessage-ID
-headers of the message you want to respond to:Request:
Response:
To follow the RFC 2822 standard we have added the
Message-ID
of the message we want to respond to to theReferences
-header, separated with a space. TheIn-Reply-To
-header also has the value of message we want to respond to. We also addRe:
to ourSubject
-header to indicate that it is a response.As you can see, this is a pain in the backside to to manually. You could also just respond to the thread. This might not be enough for your use case however.
This way, you just have to supply the mail and the
threadId
, and make sure theSubject
is the same, and Google will display it for you correctly.