title: Failed to send email: no recipient
body: <p>Good day! I need help in debugging this error: "Failed to send email: no recipient". The function sends emails based on the values of a range. Please check the code below.</p>
  
  <pre><code>  function sendArticleCountEmails() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    ss.setActiveSheet(ss.getSheetByName("Send-Emails"));
    var sheet = SpreadsheetApp.getActiveSheet();
    var dataRange = sheet.getRange(2, 1, sheet.getLastRow(), 5);
    var data = dataRange.getValues();
  
    for (i in data) {
      var rowData = data[i];
  
      var subject = 'DepEd Email/Account';
      var FirstName = rowData[0];
      var LastName = rowData[1];
      var GeneratedEmail = rowData[2];
      var Password = rowData[3];
      var emailAddress = rowData[4];
  
      MailApp.sendEmail({
      to: emailAddress,
      subject: subject,
      htmlBody: '&lt;h3&gt;' + 'Good day Mr./Mrs./Ms. '+ FirstName + ' ' + LastName +'!&lt;/h3&gt;' +
        '&lt;p&gt;Here is your email/account (email and password):&lt;/p&gt;' +
        '&lt;p&gt;&lt;span style="background-color: #ffff00;"&gt;&lt;strong&gt;&lt;a name="gEmail"&gt;' + GeneratedEmail + '&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;' +
        '&lt;p&gt;&lt;span style="background-color: #ffff00;"&gt;&lt;strong&gt;&lt;a name="pword"&gt;' + Password + '&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;' +
        '&lt;p&gt;You can now login to &lt;a href="https://mail.google.com"&gt;mail.google.com&lt;/a&gt; to check your account.&lt;/p&gt;' +
        '&lt;p&gt;If you want to change password, login first then follow this &lt;a href="https://myaccount.google.com/intro/signinoptions/password"&gt;link&lt;/a&gt;.&lt;/p&gt;'
      });
  
  
    }
  
    ss.getSheetByName('Form Responses 2').getRange(254, 12, sheet.getLastRow(), 1).copyTo(ss.getSheetByName('Form Responses 2').getRange(254, 14, sheet.getLastRow(), 1));
  
  }
  </code></pre>
  
  <p>The function runs and sends all emails but then it gives the error. I suspect it loops to an empty row and can't find a recipient but I already have dataRange with sheet.getLastRow().</p>