问题
I'm using the Gmail API directly. I was able to send a message with attached and inline attachments using this URL: https://www.googleapis.com/gmail/v1/users/me/messages/send
In the documentation, it is said that I should use the upload URI but I was not able to construct proper request for it.
Anyway, now I tried the same for creating a draft message and for some reason the inline attachments are added as attached files. I'm using the same request structure as for the 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==--
来源:https://stackoverflow.com/questions/42440023/gmail-api-uploading-inline-attachments-to-draft-message