我有一个非常简单的脚本,该脚本根据一些变量从Google工作表发送电子邮件。
我想在电子邮件中添加默认的用户签名,但是我不知道该怎么做,我已阅读文章,建议使用:
var签名= Gmail.Users.Settings.SendAs.list(“ me”)。sendAs.filter(function(account){if(account.isDefault){return true}})[0] .signature;
但是以上内容对我不起作用。
我的完整代码是:
/**
* Sends emails with data from the current spreadsheet.
*/
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 3; // First row of data to process
var numRows = sheet.getRange("H1").getValue(); // Number of rows to process and selects H1 as the range which is variable depending on selected
// Fetch the range of cells A3:B300
var dataRange = sheet.getRange(startRow, 1, numRows, 300);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
var signature = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;
for (i in data)
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = sheet.getRange("K1").getValue(); // This Function selects the data in K1 as the email subject
var body = message +" "+signature;
MailApp.sendEmail(emailAddress, subject, body);
}