title: Spreadsheets and Google Apps Script: trigger when value in cell matches
body: <p>I'm a complete beginner, but step by step I'm beginning to understand the basics of Apps Script. I found this example mail merge script on Google Dev: <a href="https://developers.google.com/apps-script/articles/mail_merge" rel="nofollow">https://developers.google.com/apps-script/articles/mail_merge</a></p>
  
  <p>This is the part of the script I'm talking about:</p>
  
  <pre><code>    function sendEmails() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var dataSheet = ss.getSheets()[0];
      var dataRange = dataSheet.getRange(2, 1, dataSheet.getMaxRows() - 1, 4);
  
      var templateSheet = ss.getSheets()[1];
      var emailTemplate = templateSheet.getRange("A1").getValue();
  
      // Create one JavaScript object per row of data.
      var objects = getRowsData(dataSheet, dataRange);
  
      // For every row object, create a personalized email from a template and send
      // it to the appropriate person.
      for (var i = 0; i &lt; objects.length; ++i) {
      // Get a row object
      var rowData = objects[i];
  
      // Generate a personalized email.
      // Given a template string, replace markers (for instance ${"First         Name"}) with
      // the corresponding value in a row object (for instance rowData.firstName).
      var emailText = fillInTemplateFromObject(emailTemplate, rowData);
      var emailSubject = "Tutorial: Simple Mail Merge";
  
      MailApp.sendEmail(rowData.emailAddress, emailSubject, emailText);
        }
      }
  </code></pre>
  
  <p>I'm trying to change the script so it only runs when the value of a cell in a specific column matches the given value. I'll give you an example:</p>
  
  <p>Using a formula in Spreadsheets the values of the cells in column E are 'Yes' if a condition is fulfilled. I want the mail merge script to only send an email if the value is 'Yes'. Furthermore I want to script to run autonomously.</p>
  
  <p><a href="http://i.stack.imgur.com/eUw4Q.png" rel="nofollow">Example Spreadsheet</a></p>
  
  <p>I was looking into using triggers to accomplish this, but right now I'm at a loss. Can you guys give me some pointers as to where to look? A friend of mine said it probably isn't possible, but I'd love a second opinion. Thanks in advance!</p>