问题:当回复电子邮件是通过api发送的,然后在接收方,它显示为包含两封电子邮件的消息(接收方良好)但发送者邮箱中有两个不同的电子邮件,邮件中有一个(发件人方面的问题)。
例如:
电子邮件从A发送到B. B再次发送给A。
在api我在“In-Reply-To”和“References”中给出了之前的电子邮件消息ID,(根据rfc822格式)这里Google正在A侧处理该消息ID但不在B处理侧。 A在单个线程中接收消息作为两条消息,但在B的帐户中,它显示为两个单独的电子邮件,一个在收件箱中,一个在已发送。
使用Api:
https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipart Content-Type:“message / rfc822; boundary = foo_bar_baz”
请求正文采用rfc2822格式
答案 0 :(得分:5)
今天在我的制作应用中也注意到了这一点。 change log没有提供发生了什么的线索,但我在managing threads的新文档中发现了问题:
- 必须在您提供的
threadId
或Message
上指定所请求的Draft.Message
。- 必须设置
References
和In-Reply-To
标头符合RFC 2822标准。- 醇>
Subject
标头必须匹配。
换句话说,需要提供threadId
。我不知道这是不是一个错误,因为它没有记录在同一天更新的sending message文档中。
我想回复收件箱中的最新消息。让我们获取相关信息:
请求1:
maxResults = 1
fields = messages/id
GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&fields=messages%2Fid
回复1:
{
"messages": [
{
"id": "15071b210a1ac883",
"threadId": "15071a4886871a10"
}
]
}
请求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
<强>响应:强>
{
"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"
}
]
}
}
剩下的就是在正确的位置创建包含所有这些数据的消息:
请求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: emtholin@gmail.com
To: emtholin@gmail.com
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/7CKmzq5nb73nvs9f9/v+zoCpRT+kQ8R/sGP9xR4T4ELPOTKh3k3P3xeD9av69rg2lYPUc11rm4sclU95RlWiNi2IIbDVFIUR5BjRUGMDohKZJ+sKLvKA2/8+XzeMbbrc2f8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4+xU5r2CNMNsyOWCV6Z4eW59jaPNrBL2QhX4W0WiXJkEV0LhioSmJpKBcDZnlRVuo/EKO2vBL7YC1YqIXGC5ygNilQKkygNuVYPyrv6Dxjsq8N4v9e8p8O6O/xdgAJ6nOBN0fGQLAAAAAElFTkSuQmCC
--foo_bar--
--foo_bar_baz--
这会产生一条新消息,其附件如前所述:
答案 1 :(得分:2)
要使它在发件人端进行线程化,您还需要将Message.threadId字段指定为send()调用的一部分。 (遗憾的是,这不会自动发生。)