I'm sending response emails through the API - it's a response to my own mail. I'm prepending 'Re: ' to the subject, adding References: and In-Reply-To: headers, with the Message-Id: of the parent.
Message is properly threaded in the receiving box, but in my outbox the email is created as a separate entity - which is not what happens if I'm using either the web interface or a desktop app.
Raws of example messages:
Original message created through the web interface (I removed addresses):
MIME-Version: 1.0
Received: by 10.37.207.3 with HTTP; Thu, 10 Dec 2015 07:39:53 -0800 (PST)
Date: Thu, 10 Dec 2015 16:39:53 +0100
Delivered-To:
Message-ID: <CAPf8QCoRSL9N18ss1hFWF+CW0Rx15typqxhJnHLHgimJ+Hv=zQ@mail.gmail.com>
Subject: wat
From:
To:
Content-Type: multipart/alternative;
Response created through the API:
Received: from 512896642660-8e1jj3ccsnam3mm1k91qn7c0k6odc316.apps.googleusercontent.com
named unknown
by gmailapi.google.com
with HTTPREST;
Thu, 10 Dec 2015 07:40:25 -0800
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
To:
From:
Subject: Re: wat
In-Reply-To: <CAPf8QCoRSL9N18ss1hFWF+CW0Rx15typqxhJnHLHgimJ+Hv=zQ@mail.gmail.com>
References: <CAPf8QCoRSL9N18ss1hFWF+CW0Rx15typqxhJnHLHgimJ+Hv=zQ@mail.gmail.com>
Date: Thu, 10 Dec 2015 07:40:25 -0800
Message-Id: <CAPf8QCq0Fh-LoC77cJ84gxERUZZMgXTuWMwG9-ZeO3LEybbkBQ@mail.gmail.com>
Here's how these messages look in my outbox , any ideas what's wrong and why the messages are not threaded?
Based on the Managing Threads in GMail API developer site, there are 3 criteria to be considered as as a thread
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested threadId must be specified on the Message or Draft.Message you supply with your request.
- The References and In-Reply-To headers must be set in compliance with the RFC 2822 standard.
- The Subject headers must match.
Since you appended "RE:" at the start, it seems that it was treated as a separate subject and wasn't included as part of the Thread.
Hope this helps!