GAS代码为谷歌片为PDF文件发送到通过电报的人(G.A.S. code to email a go

2019-10-30 03:36发布

我用下面的谷歌脚本代码来生成一个谷歌片的PDF格式,并通过电子邮件发送。 有没有一种方法,我可以通过teleram发送PDF一个人? 我应该如何更改下面的代码通过电报来发送PDF?

function emailReport() {
  readyForExport();
  var spreadsheet = SpreadsheetApp.getActive();
  var subject = spreadsheet.getRange("U1:U1").getValues();
  var emailTo = spreadsheet.getRange("V1:V1").getValues();
  var message = spreadsheet.getRange("W1:W1").getValues();
  var fileName = spreadsheet.getRange("X1:X1").getValues();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName("Students"));
  var pdf = DriveApp.getFileById(spreadsheet.getId()).getAs('application/pdf').getBytes();
  var attach = {fileName:fileName[0][0],content:pdf, mimeType:'application/pdf'};
  MailApp.sendEmail(emailTo, subject, message, {attachments:[attach]});
};
文章来源: G.A.S. code to email a google sheet as a pdf file to a person through Telegram