发送带有附件电子表格的电子邮件

时间:2019-05-12 15:29:08

标签: google-apps-script

我准备了脚本以发送带有附件电子表格的自动电子邮件,但是它将文件转换为pdf ...如何解决此问题?

function sendEmails() {
 var sheet = SpreadsheetApp.getActiveSheet();
 var startRow = 2; // First row of data to process
 var numRows = 2; // Number of rows to process
  // Fetch the range of cells A2:B3
 var dataRange = sheet.getRange(startRow, 1, numRows, 2);
 // Fetch values for each row in the Range.
 var data = dataRange.getValues();
for (i in data) {
 var row = data[i];
var emailAddress = row[0]; // First column
 var message = row[1]; // Second column
var subject = 'Sending emails from a Spreadsheet'
var waiver = DriveApp.getFileById("1rXGktttzHH8fxx2GYGs2vGrFDF9RLyp7A8oE- 
 mpgX7k")
   var liabilityWaiver = waiver.getAs(MimeType.spreadsheet);
 MailApp.sendEmail(emailAddress, message, subject, {attachments: 
 [liabilityWaiver]}); 
  }}

0 个答案:

没有答案