title: Google Apps Script - Send Email based on value in cell
body: <p>I am new with Google App Scripts and have a spreadsheet with three columns: name, overdue and last contacted: <a href="https://docs.google.com/spreadsheets/d/1W04JiFZwpGCD-qddUkNJ9xQ1xiYwZnGhissudF1EvxM/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1W04JiFZwpGCD-qddUkNJ9xQ1xiYwZnGhissudF1EvxM/edit?usp=sharing</a></p>
  <p>I would like to send an email reminder to myself which contains the name of anyone with the value overdue in column B.</p>
  <p>So far, I have only been able to write a script that sends an email to myself for row 2. I can't figure out how to get the script to loop through the values in column B.</p>
  <p>Here is my script:</p>
  <pre><code>function sendEmail() {
    
    var overdueRange = SpreadsheetApp.getActiveSpreadsheet().getRange(&quot;B2&quot;); 
    var overdueValue = overdueRange.getValue();
    if (overdueValue === &quot;Overdue&quot;){
      var nameRange = SpreadsheetApp.getActiveSpreadsheet().getRange(&quot;A2&quot;);
      var name = nameRange.getValues();
      var message = 'Reach out to ' + name 
      var subject = 'Reach out to this person.'
      MailApp.sendEmail('myemail@email.com', subject, message);
      }
  }
  
  sendEmail()
  </code></pre>