我想创建一个电子邮件/消息投掷Google API。 用户消息发送
我设法创建了一个简单的电子邮件(只有文本)使用此端点
POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/send
,并仅在身体中插入“原始”字段,其中包含此信息的基本64字符串,例如:


现在我正在尝试发送电子邮件一些附件,我无法正常工作。
我只找到了Java/JavaScript库的示例,但我想让它投掷标准REST API调用(现在我正在使用Postman来测试此端点)。
首先,我是否要使用 https:// https:// developers.google.com/gmail/api/reference/rest/v1/users.messages/send
或者
post
?
您可以留下带有正文文字和两个附件的电子邮件示例(例如两个PDF)吗?
谢谢
I want to create an email/message throw Google API. user messages send
I managed to create a simple email (only text) using this endPoint
POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/send
and inserting in the body only the "raw" field with the Base64 Encoded string that contains this info eg:


Now I'm trying to send an Email with some attachments and i can't get it to work.
I found only example with Java/Javascript libraries but I want to made it throw standard Rest Api Call (Now i'm using Postman to test this endpoints).
First of all , Have I to use https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send
OR
POST https://gmail.googleapis.com/upload/gmail/v1/users/{userId}/messages/send
?
Can you leave an example of an email with a body text and two attachments (for example two pdf) ?
Thank you
发布评论
评论(1)
如果您使用的是邮递员,我建议您按照以下步骤进行操作:
1。)使用的端点是:
https://gmail.googleapis.com/upload/gmail/gmail/gmail/v1/users/me/消息/发送?uploadType = multipart
2.)请求的内容类型标题应为:
content-type:message/rfc822
3.)请求的正文应为:<代码> RAW-&GT;文本
4.)身体的内容应具有以下格式:
作为旁注,我还遵循了REST API文档,但是由于我感到困惑,我也收到了所有类型的错误消息。但是,我找到了一个旧问题,能够帮助我制定正确的使用API的方法...您可能需要检查它 - &gt; 邮件附件错误媒体类型Gmail Api
如果您有时间也想阅读此书 - &gt; https://wwwww.rfc-editor.org/rfc/rfc/rfc/rfc/rfc2046 。阅读它有助于我克服了我正在经历的困惑,并说明了上述步骤为何奏效。
If you are using postman, I suggest you to follow these steps to make it work:
1.) The endpoint to use is:
https://gmail.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipart
2.) The content type header of the request should be:
Content-Type: message/rfc822
3.) The body of the request should be:
raw -> text
4.) The content of the body should have the following format:
As a side note, I also followed the REST API documentation but I was getting all kind of error messages because I was confused. However, I found an old question that was able to help me to formulate the correct way of using the api... you might want to check it --> Mail attachment wrong media type Gmail API
If you have time, you might also want to read this --> https://www.rfc-editor.org/rfc/rfc2046. Reading it helped me overcome the confussion I was going through and gave me clarity as to why the above steps worked.