0
I have asked something similar and someone helped me with this, but now I am trying to do something similar, but through a different sheet. I am having trouble with replacing the information throughout the script. Can anyone help me?
Here is the link to the sheet as well: Test - Google Sheets
function onSendEmail(e) {
var range = e.range.getA1Notation();
//Check if SendEmail column is edited
if(range.match(/^L[\d]+$/)){
if(e.value == true){
var sh = e.range.getSheet();
var data = sh.getDataRange().getValues();
var rowIndex = e.range.getRow()-1;
//This will prevent sending email if the header is edited
if(rowIndex > 0){
var product = data[rowIndex][3];
var email = data[rowindex][9];
var subject = 'Product Notification';
var body = 'A product you were interested in:' + product + ' is back in stock. Please contact us at 1-800-748-7001 to place an order.';
//Send email
MailApp.sendEmail(email, subject, body);
}
}
}
}