通过Gmail API发送带有内联图像和纯文本内容的电子邮件

通过Gmail API发送带有内联图像和纯文本内容的电子邮件,gmail,gmail-api,Gmail,Gmail Api,我正在使用GoogleAPI消息/发送api发送带有文本和内联图像的邮件。如果只使用html内容来嵌入图像,我可以如下定义MIME消息 Content-Type: multipart/related; boundary="0000000000000b2adf056874bbe4" --0000000000000b2adf056874bbe4 Content-Type: multipart/alternative; boundary="0000000000000b2adc056874bbe3"

我正在使用GoogleAPI消息/发送api发送带有文本和内联图像的邮件。如果只使用html内容来嵌入图像,我可以如下定义MIME消息

Content-Type: multipart/related; boundary="0000000000000b2adf056874bbe4"

--0000000000000b2adf056874bbe4
Content-Type: multipart/alternative; boundary="0000000000000b2adc056874bbe3"

--0000000000000b2adc056874bbe3
Content-Type: text/plain; charset="UTF-8"



--0000000000000b2adc056874bbe3
Content-Type: text/html; charset="UTF-8"

<img src="cid:image-Picture2.jpg">

--0000000000000b2adc056874bbe3--
--0000000000000b2adf056874bbe4
Content-Type: image/jpeg; name="Picture2.jpg"
Content-Disposition: inline; filename="Picture2.jpg"
Content-Transfer-Encoding: base64
Content-ID: <image-Picture2.jpg>

<base 64 encoded jpg image here>

--0000000000000b2adf056874bbe4--

但是,每当我发送一个非空的纯文本内容时,我总是收到没有文本内容的邮件,并且只有图像内联。我想知道如何通过gmail api发送带有内联图像的文本/纯文本。

就我试图实现这一点而言,我已经意识到只有使用HTML正文内容才能发送内联图像

--0000000000000b2adc056874bbe3
Content-Type: text/plain; charset="UTF-8"

Hello this is the text/plain content.

--0000000000000b2adc056874bbe