Google App Script google doc to mail html

时间:2015-11-19 06:09:11

标签: google-apps-script

我正在尝试将Google文档内容发送到电子邮件,但无法以html格式获取,请提供帮助。

邮件正在通过,但它不包含字体和颜色。

代码遵循:

  function getGoogleDocumentAsHTML(){
  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();

   var subject = "November 19 2015";
 MailApp.sendEmail("xxxxxx@gmail.com", subject,"", {htmlBody:html, name:"Work Program", cc:"", replyTo:"xxxxx@gmail.com"});

}

1 个答案:

答案 0 :(得分:0)

添加此....

body {-webkit-print-color-adjust:exact; }

解释了此解决方案的原因here