使用google简单邮件合并(https://developers.google.com/apps-script/articles/mail_merge)我尝试过但尝试过最后一行的电子邮件,而不是在脚本运行时通过电子邮件发送每一行。
非常感谢任何帮助!
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dataSheet = ss.getSheets()[0];
var dataRange = dataSheet.getRange(2, 1, dataSheet.getMaxRows() - 1, 4);
var templateSheet = ss.getSheets()[1];
var emailTemplate = templateSheet.getRange("A1").getValue();
// Create one JavaScript object per row of data.
var objects = getRowsData(dataSheet, dataRange);
// For every row object, create a personalized email from a template and send
// it to the appropriate person.
for (var i = 0; i < objects.length; ++i) {
// Get a row object
var rowData = objects[i];
// Generate a personalized email.
// Given a template string, replace markers (for instance ${"First Name"}) with
// the corresponding value in a row object (for instance rowData.firstName).
var emailText = fillInTemplateFromObject(emailTemplate, rowData);
var emailSubject = "Tutorial: Simple Mail Merge";
MailApp.sendEmail(rowData.emailAddress, emailSubject, emailText);
}
}
答案 0 :(得分:0)
固定:如果有人对此感兴趣:
变化:
var rowData = objects[i]
为:
var rowData = objects[objects.length-1];
和
for var (i = 0; i < objects,length; ++i) {
只是:
var i = 0; i < objects,length; ++i;