Google apps script 脚本只向列表中的最后一个人发送电子邮件
电子邮件只发送给列表中的最后一个人,我不知道为什么。我假设这与我的数据范围有关,但我在编码方面不是很有经验。如果有人能帮忙,那就太好了 试试这个:Google apps script 脚本只向列表中的最后一个人发送电子邮件,google-apps-script,Google Apps Script,电子邮件只发送给列表中的最后一个人,我不知道为什么。我假设这与我的数据范围有关,但我在编码方面不是很有经验。如果有人能帮忙,那就太好了 试试这个: /** * Sends emails with data from the current spreadsheet. */ function sendEmails() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data
/**
* Sends emails with data from the current spreadsheet.
*/
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 72; // Number of rows to process
// Fetch the range of cells A2:K73
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[1];
var name = row[4];
var subject = 'Discovery High School Lunar New Year Volunteering';
var message = "Good Evening " + name + "," + '\n'+ " " + '\n'
+ "This is a reminder about High School Lunar New Years Festival." + '\n'
+ " " + '\n'
+ "The event is this ." + '\n'
+ "We also have setup after school on " + '\n'
+ " " + '\n'
+ "More information about shifts and jobs will be emailed out soon. Please stay updated and if you have questions, reply to this email or ask your officers." + '\n'
+ " " + '\n'
+ "Thank you for your help." + '\n'
}
MailApp.sendEmail(emailAddress, subject, message);
}
非常感谢。必须是范围定义。否。这可能是MailApp.sendmail命令的位置。它不在循环中。
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 72; // Number of rows to process
// Fetch the range of cells A2:K73
var dataRange = sheet.getRange(startRow, 1, numRows, 11);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[1];
var name = row[4];
var subject = 'Discovery High School Lunar New Year Volunteering';
var message = "Good Evening " + name + "," + '\n'+ " " + '\n'
+ "This is a reminder about High School Lunar New Years Festival." + '\n'
+ " " + '\n'
+ "The event is this ." + '\n'
+ "We also have setup after school on " + '\n'
+ " " + '\n'
+ "More information about shifts and jobs will be emailed out soon. Please stay updated and if you have questions, reply to this email or ask your officers." + '\n'
+ " " + '\n'
+ "Thank you for your help." + '\n'
MailApp.sendEmail(emailAddress, subject, message);
}
}