在查看了提供的使用 Google Apps 脚本从电子表格发送电子邮件的教程后,我修改了给定的代码,目的是能够将这组电子邮件连同附件一起发送出去。
它运行良好,即使有一些来自 Google Apps Script 限制的怪癖(文件必须在 Google Drive 中,并且 Google Drive 中的所有文件都取自驱动器中的所有文件夹)。
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1; // Number of rows to process
// Fetch the range of cells A2:C3
var dataRange = sheet.getRange(startRow, 1, numRows, 3)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = …
Run Code Online (Sandbox Code Playgroud)