0

I have a Google spreadsheet that I created to track daily equipment inspections. The data in the sheet comes from a form that is filled out by whoever inspects the equipment for that day.

Here's a link to the sheet: https://docs.google.com/spreadsheets/d/1Ovpv7Dn1eJZ_tLZDCPF5elMS_L5doqtBhCIjKCYdFD0/edit?usp=sharing

Basically, I want an email sent to me if anything comes back as NOT OK indicating the truck #, what was not ok and any additional comments.

I tried creating a script but it's not working:

function sendemails()

{

var sheet = SpreadsheetApp.getActive();

var startRow = 2; 

var data = dataRange.getValues();

for (var i = 0; i < data.length; ++i) {
var row = data[i];
var message = row[1];
var emailSent = row[2];
if (emailSent != EMAIL_SENT) { 
      var subject = 'Sending emails from a Spreadsheet';
  MailApp.sendEmail("test@gmail.com", "Attention required", "The following issues were highlighted during an inspection:");
      sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT);
      SpreadsheetApp.flush();


}

}

}

Any help would be appreciated, Thanks!

  • Edits should not replace the core content of the questions when it already received a good answer because that could invalidate that answer. The added content should be posted as a new question and the last edit of this quetions should be reverted. – Rubén Dec 5 '18 at 21:43
  • Done. Will post a new question. – shubar w Dec 6 '18 at 3:58
0

Answer for revision 1

EMAIL_SENT is not defined. You could figured out by yourself if you use the tools and techniques described on https://developers.google.com/apps-script/guides/support/troubleshooting, like using the built in debugger and commands like console.log.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.