title: Google Apps Script - Automated Email Based on Cell Value
body: <p>I'm a total noob when it comes to working with scripts and I'm looking for some help with one that I borrowed and modified to work with my spreadsheet. </p>
  
  <p>I am looking for the value "Need to Order" in column H that will then cause an email to be sent out to a recipient. The only problem I'm having is that every time a value in that column is changed and my "Need to Order" text is present in one of the other cells in the column, an email gets sent out and my inbox gets flooded. Can someone help me tweak it so that it doesn't generate an email if any of the other cells in the column already have the "Need to Order" value present?</p>
  
  <p>Thanks for any help you can afford. </p>
  
  <p>Here's what I'm working with:</p>
  
  <pre><code>function sendEmail(email_address, email_subject, email_message) {
    var status = ScriptProperties.getProperty('AlertStatus')+"";
    var value = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Vehicle Inventory").getRange( "H2:H100").getValues().toString();
    if (value.match("Need to Order" )&amp;&amp;status.match("")) { 
      ScriptProperties.setProperty('AlertStatus', '') 
      MailApp.sendEmail('username@gmail.com', 'Need to Order', 'Order more equipment.     Open the current version of your Google Document "test spreadsheet": ');
  }
   else { 
      if (!value.match("Need to Order" )) 
      ScriptProperties.setProperty('AlertStatus', '') 
   }
  }​    
  </code></pre>