我直接使用Gmail API。我能够使用此URL发送带有附件和内联附件的邮件: https://www.googleapis.com/gmail/v1/users/me/messages/send
在文档中,据说我应该使用上传URI,但我无法为其构建正确的请求。
无论如何,现在我尝试了同样的方法来创建草稿消息,并且出于某种原因,内联附件被添加为附加文件。我使用与send:
相同的请求结构From:
Date: Fri, 24 Feb 2017 10:22:27 +0000
Subject: [subject]
Message-Id: [internetMessageId]
Importance: low
To: [receiver]
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-knCVLgE13LKcqJaIUhH/sg=="
--=-knCVLgE13LKcqJaIUhH/sg==
Content-Type: multipart/related; boundary="=-y0HXgc0QJcTY91BQZr4YAw=="
--=-y0HXgc0QJcTY91BQZr4YAw==
Content-Type: multipart/alternative; boundary="=-8wbiVX9FveJH/GI7+yiHtg=="
--=-8wbiVX9FveJH/GI7+yiHtg==
Content-Type: text/plain; charset=utf-8
4 draaaaft
some text here and then the image:
some more text
--=-8wbiVX9FveJH/GI7+yiHtg==
Content-Type: text/html; charset=utf-8
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p> 4 draaaaft</p>
<p>some text here and then the image:</p>
<p><img size="3542" tabindex="0" src="cid:1112ed9d-acf8-4144-aa40-2468a3943eb7" style="max-width:99.9%"></p>
<p>some more text</p>
</div>
</body>
</html>
--=-8wbiVX9FveJH/GI7+yiHtg==--
--=-y0HXgc0QJcTY91BQZr4YAw==
Content-Type: image/jpeg; name=pic3.jpeg
Content-Id: <1112ed9d-acf8-4144-aa40-2468a3943eb7>
Content-Disposition: inline; filename=pic3.jpeg
Content-Transfer-Encoding: base64
[file content in base64]
--=-y0HXgc0QJcTY91BQZr4YAw==--
--=-knCVLgE13LKcqJaIUhH/sg==
Content-Type: application/pdf; name="file attached.pdf"
Content-Disposition: attachment; filename="file attached.pdf"
Content-Transfer-Encoding: base64
[file content in base64]
--=-knCVLgE13LKcqJaIUhH/sg==--