I need to automate sending emails for a list of people in google sheets. I have never used App Script or Java but made some simple code based on tutorials, to fit what I need. Unfortunately it doesn’t work and I have no idea why. Can someone look into it and spot what’s wrong?
I made an example sheet just to show how the data is arranged in my spreadsheet – https://docs.google.com/spreadsheets/d/1Wozh95kWBCP5EsCCH6bCcn9S39oHEU0Zf78B1qtUFho/edit?usp=sharing
I have rows for the email, subject and body, a static call for a bcc and a checkbox to be able to exclude some rows manually. When I try to run the script to send an email to myself, it executes and nothing happens. Here is the script:
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('People1');
var values = ss.getDataRange().getValues();
var ebcc = ss.getRange(2, 6).getValue()
for (var i = 0; i > values.length ;i++){
if (values[i][3] == true) {
var theEmail = ss.getRange(i,3).getValue();
var theSubject = ss.getRange(i,4).getValue();
var theBody = ss.getRange(i,5).getValue();
GmailApp.sendEmail(theEmail, theSubject, theBody, {bcc: ebcc})
}
}
}
Mikołaj Gano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.