2015-12-10 65 views
2

我通過API發送響應電子郵件 - 這是對我自己郵件的回覆。我在主題前添加了「Re:」,添加了References:和In-Reply-To:標頭,並帶有Message-Id:父項。Gmail API - 郵件無線程:已發送

郵件在收件箱中正確地線程化,但在我的發件箱中,電子郵件是作爲單獨的實體創建的 - 如果我使用的是Web界面或桌面應用程序,則不會發生這種情況。示例的

原糖消息:

通過網絡界面創建

原始消息(I刪除地址):通過API創建

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: <[email protected]om> 
    Subject: wat 
    From: 
    To: 
    Content-Type: multipart/alternative; 

響應:

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: <[email protected]om> 
    References: <[email protected]om> 
    Date: Thu, 10 Dec 2015 07:40:25 -0800 
    Message-Id: <[email protected]om> 

Here's how these messages look in my outbox ,任何想法什麼是錯的,爲什麼消息不是線程的?

+1

可能重複的[Gmail API In-Reply-To not working(Google not handling on one side)](http://stackoverflow.com/questions/33171769/gmail-api-in-reply-to-not- workinggoogle-not-handling-on-one-side) – Richard

回答

1

基於GMail中API的開發者網站的Managing Threads,有3倍被認爲是作爲一個線程

爲了線程,郵件或草稿必須滿足以下條件的一部分的標準:

  • 請求的threadId必須在提供請求的Message或Draft.Message中指定。
  • 引用和In-Reply-To頭部必須設置爲符合RFC 2822標準。
  • 主題標題必須匹配。

既然你追加的「RE:」在一開始,似乎它被視爲一個單獨的主體,沒有被列入爲主題的一部分。

希望這會有所幫助!

+0

我發現[此線程](http://stackoverflow.com/questions/33171769/gmail-api-in-reply-to-not-workinggoogle-not-稍後處理一邊/ 33177031#33177031),這解決了這個問題。 –

+0

在API發送[示例](https://developers.google.com/gmail/api/guides/sending)中,需要將'threadId'屬性添加到從CreateMessage返回的字典中。 –

+0

剛剛測試過這個:如果設置了ThreadId,那麼添加「Re:」前綴不會中斷GMail端的線程。 – Richard