如何使用GmailApp_2发送富文本电子邮件?

时间:2017-10-12 12:20:55

标签: google-apps-script gmail-api google-docs-api

它来自first question

function emailGoogleDoc(){
var id = DocumentApp.getActiveDocument().getId() ;
var forDriveScope = DriveApp.getStorageUsed(); //needed to get Drive Scope 
requested
var url = "https://docs.google.com/feeds/download/documents/export/Export?
id="+id+"&exportFormat=html";
var param = {
method      : "get",
headers     : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
};
var html = UrlFetchApp.fetch(url,param).getContentText();
Logger.log(html);

var email = person@domain.tld;  
var subject = 'Subject line';
var body = "To view this email, please enable html in your email client.";

MailApp.sendEmail(
    email,           // recipient
    subject,         // subject 
    body, {          // body
    htmlBody: html // advanced options
  }
);
}

嗨!我遇到了这段代码的麻烦。

除了文字外,它运行得很完美。它没有大胆或颜色。

1 个答案:

答案 0 :(得分:0)

MailApp.sendEmail({       发邮件,       主题:主题,       htmlBody:html       });