Google Apps Script Getting "Exception: Failed to send email: no recipient" error but emails are sent

17 views Asked by At

I am getting the above message as an error even though the emails are sent and received in their respective inboxes/recipients. Just want to make sure the code is clean. I'm not a pro at coding. Any help is greatly appreciated! Code is below:

function sendEmailAI() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var responses1 = ss.getSheetByName("sendmail_br");
  var responses2 = ss.getSheetByName("sendmail_br");

  var data1 = responses1.getRange(11,3,3,2).getValues();
  var data2 = responses2.getRange(17,20,responses2.getLastRow() -1,4).getValues(); 

  var EmailSubject = data1[0][0]; //Row 1 and Col 1 of data1 range
  var EmailBody    = data1[1][0];
  var EmailFooter  = data1[2][0];

  data2.forEach(function (row,i) {
    MailApp.sendEmail(row[1] , EmailSubject,'Hello ' + ',\n\n' + EmailBody + ' ' + row[0] + '\n\n' +      
     EmailFooter);
  }); 

}

I tried to change the get.Range but same error.

0

There are 0 answers