anon
anon

Reputation:

Cannot keep messages in the same conversation due to missing MESSAGE-ID header at Gmail

At some messages in Gmail, the MESSAGE-ID header is missing and I need to use it as IN-REPLY-TO header when replying so I can keep the replies at the same conversation. When those emails with missing MESSAGE-ID header are replied from the Gmail's WEB UI, the replies stay with the conversation and the reply in fact acquires a IN-REPLY-TO header something looks like <-4185615914882731559@unknownmsgid> I could not discover how is this generated.

I've been trying to find a solution to this problem quite a while, ended up trying a few desktop email clients, Airmail and Sparrow to see how they behave. If I ever reply a particular email which is missing the MESSAGE-ID header using those email clients, the sent reply also acquires the same IN-REPLY-TO header <-4185615914882731559@unknownmsgid> and the reply indeed stays at the same conversation as expected.

So, I would like to ask how they achieve this, do they somehow generate the IN-REPLY-TO header <-4185615914882731559@unknownmsgid>? Is there a rule or a workaround?

Upvotes: 1

Views: 1869

Answers (3)

arnt
arnt

Reputation: 9685

This is a classic problem, every mail reader has it. The classic solution is:

  • copy the References field from the message you reply to, if any.
  • make up an In-Reply-To field, perhaps with a made-up message-id, perhaps with the sender's address and the message's date.
  • Keep the subject, and append "re: ".
  • You may also copy the Thread-Index field, if there is one.

Gmail's and most other threading algorithms will then connect the dots.

Thread-Index is a Microsoft thing, noone else uses it, as far as I know. The format of the hex blob is not specified, but copying that will help probably help Exchange, if the original message comes from Exchange.

Upvotes: 4

Chris Lear
Chris Lear

Reputation: 6742

I don't think that e-mails delivered to your gmail account have no message id. My evidence is that I just tried sending one to myself via telnet without a message id, and gmail's mx server added this

Message-Id: <54412844.63bbb40a.0772.ffffcbdcSMTPIN_ADDED_MISSING@mx.google.com>

It may be that copying a message into gmail's imap store can result in a missing message id. Eg see https://productforums.google.com/forum/#!topic/gmail/w5kgRivwbIg (though that is very old, it shows that synchronising mail to a gmail IMAP account can have this result).

The basic rule of e-mail is that if an e-mail doesn't have a message id for whatever reason, one is created for it, which is what has happened here. Hence, when you reply, the made-up message id is used in the in-reply-to header.

Upvotes: 1

Eric D
Eric D

Reputation: 7159

If you just want to send an email and make sure it threads with another email in that user's inbox (and not any other gmail users that may receive the reply) then I believe you can use the Gmail API's messages.send() method and set the message.threadId to match the thread you want it to thread with.

Upvotes: 1

Related Questions