I use the following code to send reminder emails to all the emails that are in a certain cell in column 7. But, it gives an error that "Cannot find SendEmail function". Would anyone please help me?
function myfunction() {
var sheet = SpreadsheetApp.getActiveSheet();
// figure out what the last row is
var lastRow1 = sheet.getLastRow();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 5
var startRow1 = 5;
// grab column 6 (the 'days left' column)
var range = sheet.getRange(5,6,lastRow1-startRow1+1,1 );
var numRows = range.getNumRows();
var days_left_values = range.getValues();
// Now, grab the reminder name column
range = sheet.getRange(5, 3, lastRow1-startRow1+1, 1);
var reminder_info_values = range.getValues();
range = sheet.getRange(5, 7, lastRow1-startRow1+1, 1);
var emails_info_values = range.getValues();
var warning_count = 0;
var msg = "";
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if(days_left == 1) {
// if it's exactly 1, do something with the data.
var reminder_name = reminder_info_values[i][0];
msg = msg + "Reminder: "+reminder_name+" is due in "+days_left+" days.\n";
warning_count++;
}
var emails= emails_info_values [i][0];
if(warning_count) {
MailApp.sendEmail("emails", "msg");
}
}
}
if(days_left =1= 0) {- CooperMailApp.sendEmail("emails", "msg");I think they should be variables. - Cooper