谷歌脚本发送带有图像的Excel附加文件

时间:2019-01-28 14:59:48

标签: excel google-apps-script

我有一个带有脚本的google工作表,该脚本以Excel格式发送附件中的工作表。我的一列是图片,是否可以在.XLS中添加它?列的图像保持空白。

function sendEmail() {

  var ssID = SpreadsheetApp.getActiveSpreadsheet().getId();

  var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("name_of_sheet_to_send");

  //var email = Session.getUser().getEmail();    
  var email_ID1 = "email@email1";    
  var subject = "Dates de livraisons erronées";    
  var body = "Hello! Ci-joint la liste des refs dont la date de livraison est antérieure à la date de livraison possible. Happy birthday! (Coeur avec les mans) ";

  var requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};
  var shID = "xxxxxxxx";
  var url = "https://docs.google.com/spreadsheets/d/"+ ssID + "/export?format=xlsx&id="+ssID+"&gid="+shID;

  var result = UrlFetchApp.fetch(url , requestData);  
  var contents = result.getContent();

  MailApp.sendEmail(email_ID1,subject , body, {attachments:[{fileName:sheetName+".xls", content:contents, mimeType:"application//xls"}]});

0 个答案:

没有答案