我正在关注如何从Google表格发送电子邮件的Google脚本教程。
代码工作正常,我运行时会收到一封电子邮件。但是,当我检查收件箱时,而不是在预览中显示我姓名的标题时,它会显示完整的电子邮件地址。
以下是教程中的代码:
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";
MailApp.sendEmail(emailAddress, subject, message);
}
}
答案 0 :(得分:2)
如何修改脚本?
MailApp.sendEmail(emailAddress, subject, message);
MailApp.sendEmail(emailAddress, subject, message, {name: '### Your name ###'});
如果这对你没用,我很抱歉。