我想使用Google Apps脚本创建Gmail电子邮件草稿,例如以下示例摘自Mogsdad对Create draft mail using Google apps script问题的接受答案:
function createDraft() {
var forScope = GmailApp.getInboxUnreadCount(); // needed for auth scope
var raw =
'Subject: testing Draft\n' +
//'To: test@test.com\n' +
'Content-Type: multipart/alternative; boundary=1234567890123456789012345678\n' +
'testing Draft msg\n' +
'--1234567890123456789012345678--\n';
var draftBody = Utilities.base64Encode(raw);
var params = {method:"post",
contentType: "application/json",
headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
payload:JSON.stringify({
"message": {
"raw": draftBody
}
})
};
var resp = UrlFetchApp.fetch("https://www.googleapis.com/gmail/v1/users/me/drafts", params);
Logger.log(resp.getContentText());
效果很好,但我希望在邮件正文中嵌入一些图片,而不会链接到外部网址,因此它总是会显示,而不会被某些电子邮件客户端阻止,包括Gmail。怎么做?