本文介绍了使用Google Apps脚本中的GMail API发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一封原始电子邮件(在运动场和工作场所进行过测试),我希望通过Google的。

I have a raw email (tested on playground and working) and I want to send it with Google's Gmail API from Google Apps Script.

我无法找到正确的请求语法:

I can't find the right syntax for the request:

var RequestUrl = "https://www.googleapis.com/gmail/v1/users/emailAccount/messages/send";

var RequestArguments = {
    muteHttpExceptions:true,
    headers: {Authorization: 'Bearer ' + token
             'GData-Version': '3.0',
             'Content-Type': "message/rfc822",
             },
    payload: {"raw":raw},
    method:"post"
  };

var result = UrlFetchApp.fetch(RequestUrl,RequestArguments);

我的语法出了什么问题?

What is wrong with my syntax?

推荐答案

我找到了解决我的问题的方法:

I found the solution to my question:

var RequestArguments = {
  headers: {Authorization: 'Bearer ' + token},
  method: "post",
  contentType: "application/json",
  payload: JSON.stringify(jsonMessage)
};

jsonMessage是整个消息,不仅是原始部分!

jsonMessage is the whole message, not only the raw part!

这篇关于使用Google Apps脚本中的GMail API发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:33