Creating an Automatic Email Script, I have done it before, but I am having trouble replacing the info

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);
      }
    }    
  }
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you. Sorry about that.