Skip to content
Advertisement

How correctly set “In-Reply-To” and “Reference” headers in Gmail API

I’m trying to reply a mail I received using Gmail API. I tried following code it appends the sending message to thread in my mailbox but for the receiver it send as a new message. What is the proper way to declare In-Reply-To and Reference headers?

JavaScript

My main method is as follow,

JavaScript

Advertisement

Answer

The create_message method should be changed as follow to set ‘Reference’ and ‘In-Reply-To’ headers.

JavaScript

The correct msgID can be obtained from following method,

JavaScript

The msgID can be obtained as follow,

JavaScript

Do not confuse msg_id with msgID. msg_id is gmail specific and msgID is global. This msgID should be used in ‘Reference’ and ‘In-Reply-To’ headers.

Advertisement