Gmail REST API:发送带附件的回复邮件uploadType = media

时间:2017-10-26 13:31:56

标签: gmail-api mime-message

我真的需要你的帮助! 我想发送一封包含Gmail REST API的回复邮件。使用标准网址: https://www.googleapis.com/gmail/v1/users/userId/messages/send,一切正常。通过发送消息的原始数据和线程id,新消息将附加到同一个线程。

现在我希望我们的客户能够上传更大的附件我使用上传网址:https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=media

我将带有Content-Type设置的请求发送到文档中设置的message / rfc822,但我找不到发送Thread ID的方法。 我尝试将它作为标题(例如:Thread-Id)添加到MimeMessage,但它只在我将消息发送到Outlook时才有效 - 消息被发送到同一个线程。 我还填充了In-Reply-To标头,References标头和Subject与原始线程中的主题相同,附加了“Re:”。 Gmail仍会为此邮件创建新主题。

更新 我尝试使用带有参数uploadType = multipart的upload uri,这是我的请求:

Content-Type: multipart/related; boundary="=-EEoaSdATsa0it8EbymRVdg=="

--=-EEoaSdATsa0it8EbymRVdg==
Content-Type: application/json
Content-Transfer-Encoding: base64

eyJ0aHJlYWRJZCI6IjE1ZTdlZmJhYTc3MzViZjcifQ==

--=-EEoaSdATsa0it8EbymRVdg==
Content-Type: message/rfc822

From: deni.gencheva@gmail.com
Date: Fri, 27 Oct 2017 16:13:37 +0300
Subject: Re: RE:
Message-Id: <ESXEYD0PP2U4.RL2HHWMRGNXE@localhost.localdomain>
Sender: {sender email}
Reply-To: {sender email}
To: {one receiver email}
In-Reply-To: 
 =?us-ascii?q?
=3CHE1PR0402MB3323926A291565E98E66C1DCFC720=40HE1PR0402MB3323=2Eeur?=
 =?us-ascii?q?prd04=2Eprod=2Eoutlook=2Ecom=3E?=
References:<HE1PR0402MB3323926A291565E98E66C1DCFC720@HE1PR0402MB3323.eurprd04.prod.outlook.com>
<CAJM2npmj3DWntngux8KovxPoNJ+KOS4tKm=LAo1YoG3vxWLQdg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-VCM8QFnp+o3VG1fmByraaw=="

--=-VCM8QFnp+o3VG1fmByraaw==
Content-Type: application/octet-stream; name="test document.rtf"
Content-Disposition: attachment; filename="test document.rtf"
Content-Transfer-Encoding: base64
Content-Id: <5e655580-14b6-0d1f-9e86-ad1c590691db>

{attachment base64 encoded content}

--=-VCM8QFnp+o3VG1fmByraaw==
Content-Type: multipart/alternative; boundary="=-pst5gHw2fNhIKAdrMRT2wg=="

--=-pst5gHw2fNhIKAdrMRT2wg==
Content-Type: text/plain; charset=utf-8

{message body as plain text}

--=-pst5gHw2fNhIKAdrMRT2wg==
Content-Type: text/html; charset=utf-8

{message body as html}

--=-pst5gHw2fNhIKAdrMRT2wg==--

--=-VCM8QFnp+o3VG1fmByraaw==--

--=-EEoaSdATsa0it8EbymRVdg==--

但API会返回一个错误,指出multipart / related不是允许的内容类型。

0 个答案:

没有答案
相关问题