I am new with Google App Scripts and have a spreadsheet with three columns: name, overdue and last contacted: https://docs.google.com/spreadsheets/d/1W04JiFZwpGCD-qddUkNJ9xQ1xiYwZnGhissudF1EvxM/edit?usp=sharing
I would like to send an email reminder to myself which contains the name of anyone with the value overdue in column B.
So far, I have only been able to write a script that sends an email to myself for row 2. I can't figure out how to get the script to loop through the values in column B.
Here is my script:
function sendEmail() {
var overdueRange = SpreadsheetApp.getActiveSpreadsheet().getRange("B2");
var overdueValue = overdueRange.getValue();
if (overdueValue === "Overdue"){
var nameRange = SpreadsheetApp.getActiveSpreadsheet().getRange("A2");
var name = nameRange.getValues();
var message = 'Reach out to ' + name
var subject = 'Reach out to this person.'
MailApp.sendEmail('[email protected]', subject, message);
}
}
sendEmail()

sendEmailtwice like that. careful also withgetValueswhich returns a 2d array. Also in this way you are requesting for the active sheet. Instead, specify the sheet name. This won't work as a time driven trigger function if you are planning to use an active sheet like that. After you sort all of this out you can think of how you can create a loop. - soMario