问题描述
问题:当通过 api 发送电子邮件回复时,在接收方显示为包含两封电子邮件消息的线程(接收方良好)但发件人有两封不同的电子邮件,一封在收件箱中,一封在已发送邮件中(发件人方面的问题).
例如:
电子邮件从 A 发送到 B.B 再次发送给 A.
在 api 中,我在In-Reply-To"和References"中提供上一个电子邮件消息 ID,(根据 rfc822 格式)这里 Google 正在处理 A 端的消息 ID,但不在 B 端边.A 在单个线程中以两封邮件的形式接收邮件,但在 B 的帐户中,它显示为两封单独的电子邮件,一封在收件箱中,一封在发送中.
使用的 API:
Problem: When Reply to email is sent via api then in receiver side it is showing as thread that contains two email messages(good on receivers side) but the sender has two different emails one in Inbox and one in Sent Mail(Problem in sender side).
for example:
Email is sent from A to B.Again B sends to A.
here in api i am giving the previous email message-id in "In-Reply-To" and "References",(according to rfc822 format) here Google is handling that message-id on the A side but not on B side. A receives the message in a single thread as two messages but in B's account it is showing as two separate emails one in Inbox and one in sent.
Api used:
https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipartContent-Type: "message/rfc822; boundary=foo_bar_baz"
request body is in rfc2822 format
Noticed this in my production app today as well. The change log did not give a clue as to what happened, but I found the problem in the new documentation for managing threads:
In other words, the threadId
needs to be supplied. I don't know if this is a bug or not, since it is not documented in the sending message-documentation that was updated on the same day.
I want to respond to the latest message in my inbox. Let's get the relevant information:
Request 1:
maxResults = 1
fields = messages/id
GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&fields=messages%2Fid
Response 1:
{
"messages": [
{
"id": "15071b210a1ac883",
"threadId": "15071a4886871a10"
}
]
}
Request 2:
format = metadata
metadataHeaders = In-Reply-To,References,Message-ID,Subject
fields = payload/headers
GET https://www.googleapis.com/gmail/v1/users/me/messages/15071b210a1ac883?format=metadata&metadataHeaders=In-Reply-To&metadataHeaders=References&metadataHeaders=Message-ID&metadataHeaders=Subject&fields=payload%2Fheaders
Response:
{
"payload": {
"headers": [
{
"name": "In-Reply-To",
"value": "<CADsZLRyej6wRwCNYv91+dBu9uYhuqYo4pEqOpt41NftXJJqC7g@mail.gmail.com>"
},
{
"name": "References",
"value": "<CADsZLRyej6wRwCNYv91+dBu9uYhuqYo4pEqOpt41NftXJJqC7g@mail.gmail.com>"
},
{
"name": "Message-ID",
"value": "<CADsZLRzipMRrQv-A9m-r-EJafXXm1eS9ihw3ZD5g8ybfj+LYeg@mail.gmail.com>"
},
{
"name": "Subject",
"value": "Re: Perculiar"
}
]
}
}
All that is left is to create a message with all this data in the right places:
Request 3:
POST https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipart
Content-Type: multipart/related; boundary="foo_bar_baz"
--foo_bar_baz
Content-Type: application/json; charset=UTF-8
{
"threadId": "15071a4886871a10"
}
--foo_bar_baz
Content-Type: message/rfc822
Content-Type: multipart/mixed; boundary="foo_bar"
In-Reply-To: <CADsZLRzipMRrQv-A9m-r-EJafXXm1eS9ihw3ZD5g8ybfj+LYeg@mail.gmail.com>
References: <CADsZLRyej6wRwCNYv91+dBu9uYhuqYo4pEqOpt41NftXJJqC7g@mail.gmail.com> <CADsZLRzipMRrQv-A9m-r-EJafXXm1eS9ihw3ZD5g8ybfj+LYeg@mail.gmail.com>
From: [email protected]
To: [email protected]
Subject: Re: Perculiar
--foo_bar
Content-Type: text/html; charset="UTF-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
<div dir="ltr"><b> This is where the message text goes </b></div>
--foo_bar
Content-Type: image/png
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="cool.png"
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAADd9JREFUeNrsWnuQXFWZ/+6j+/ZzeiYzk5lkHkkIM3nikIeTEARqNYRSKRXcxQGxLAqipiJBUlIqurvlupavKikpdpFQiFVLJOADUcLKbBCVoCRAkCSEJJPJTCbT8+qeft7345z9zr2nZzoyIRMS/7CKmzq5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DtyIBUyU/VCDq5H9RBbrvG6N0tJ1jRyv7xBC0QZsSGLYMyDBFxidxKjyPIx3nVh6FmvLCSt94GXj5AtvcWRR+UwpwxPWmClszksBQTgnrWE3sPF33O+yAOoYP8MV4+xU5r2CNMNsyOWCV6Z4eW59jaPNrBL2QhX4W0WiXJkEV0LhioSmJpKBcDZnlRVuo/EKO2vBL7YC1YqIXGC5ygNilQKkygNuVYPyrv6Dxjsq8N4v9e8p8O6O/xdgAJ6nOBN0fGQLAAAAAElFTkSuQmCC
--foo_bar--
--foo_bar_baz--
This results in a new message with an attachment threaded like before:
这篇关于Gmail API In-Reply-To 不工作(谷歌不处理一方面)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!