I want the script to send an email to those mail addresses where unchecked boxes are in the row. - This works fine. But I want the value of the checkbox to be set “True” afterwards. In other words: The checkboxes to which mails were sent should change to the value “True”. The error is in the range >> "ss.getRange (v + i, 3)" I don't know how to pick the range to solve the problem. Appreciate any help – thanks a lot!
function sendmail() {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('Sheet1');
var r = s.getRange('C:C'); //Checkboxes
var v = r.getValues();
for(var i=v.length-1;i>=0;i--)
if(v[0,i]=='false') {
var range = ss.getRange("A1:D4");
var UserData = range.getValues();
var UserData = range.getValues();
var row = UserData[i];
var name = row[0];
var email = row[1];
MailApp.sendEmail(row[1], "Test", "Hello " + name + ", This is an email");
var response = ui.alert("mail was send to ", ui.ButtonSet.OK);
if (response == ui.Button.OK) {
ss.getRange(v + i, 3).setValue("TRUE");
}
}
}
Aucun commentaire:
Enregistrer un commentaire