title: Auto-Generated Email Based on Cell Values
body: <p>I am having trouble with my code and I'm not sure what's missing. I've built code a few times before but I am by no means an expert.</p>
  
  <p>I am trying to send automatic email reminders when a cell value equals 30. My code successfully runs but it doesn't generate an email at all. What am I doing wrong?</p>
  
  <p>I'm not sure what else to try, I've searched up how to make this happen but it isn't making sense to me on how exactly to make this happen.</p>
  
  <pre><code>function sendEmail(){
  var sSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
  var Dept = sSheet.getRange(1, 1, sSheet.getLastRow(), 1);
  var PDName = sSheet.getRange(1, 3, sSheet.getLastRow(), 3);
  var HRPname = sSheet.getRange(1, 26, sSheet.getLastRow(), 26);
  var HRPemail = sSheet.getRange(1, 27, sSheet.getLastRow(), 27);
  var AnniversaryDate = sSheet.getRange(1, 12, sSheet.getLastRow(), 12);
  var DaysUntilAnni = sSheet.getRange(1, 13, sSheet.getLastRow(), 13);
  
  
  if (DaysUntilAnni == 30){
    var subject = "Upcoming Postdoc Anniversary: " + PDName + " - " + AnniversaryDate;  
    var message = "Hi " + HRPname + "," + "\n\n" + "The Postdoc appointment for "+PDName+" in "+Dept+" has an appointment end date and/or anniversary date coming up on "+AnniversaryDate+". Please review this postdoc appointment and" +
                   "\n\n" + "take necessary action to extend their appointment and/or update level change based on their anniversary date." +
                   "\n\n" + "Please update the BEST Postdoc Tracker no later than " +AnniversaryDate+ " once the actions have been completed."
  
                   "\n\n" + "You will continue to receive weekly reminders regarding this action until the appointment end date or anniversary date has been updated in the BEST Postdoc Tracker.";     
    MailApp.sendEmail(HRPemail, subject, message);
   }  
  }
  </code></pre>
  
  <p>My code should run daily and it should send emails to the appropriate people as listed in the google sheet.</p>