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:
jsonMessage is the whole message, not only the raw part!
In Google Apps Script, you can use the Advanced Gmail Service without needing to fuss with the Web API directly. Remember, the service must be enabled before use.