Im running a script to help a group keep track of translations. The goal is to have the translator notified (emailed) when a document is updated (each language has it's own sheet within the doc). Each recipients email is listed in it's own cell in the row of the document they are responsible for translating. The script will run occasionally, but I think it is getting caught up on cells that have text (not emails) listed where email addresses should be.
I keep getting the error: 'Failed to send email: no recipient (line 21, file "Translation Notification")'
Is there a way to update my script so that it will invalid email recipients?
function shellFunction() {
var sheets = ['Arabic', 'Portuguese', 'French','Spanish'];
for (var s in sheets) {
toTrigger(sheets[s]);
}
}
function toTrigger(sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
var cell = ss.getActiveCell().getA1Notation();
var row = sheet.getActiveRange().getRow();
var cellvalue = ss.getActiveCell().getValue().toString();
var recipients = sheet.getRange('J' + sheet.getActiveCell().getRowIndex()).getValue();
var message = '';
if (cell.indexOf('B') != -1)
{
message = sheet.getRange('A' + sheet.getActiveCell().getRowIndex()).getValue()
}
var subject = 'The ' + sheet.getRange('F' + sheet.getActiveCell().getRowIndex()).getValue() + ' ' + sheet.getRange('A' + sheet.getActiveCell().getRowIndex()).getValue() + ' needs your Translation';
var body = sheet.getRange('A' + sheet.getActiveCell().getRowIndex()).getValue() + ' has been updated. Can you please update ' + sheet.getRange('G' + sheet.getActiveCell().getRowIndex()).getValue() + '? Please remember to update the date column in the Resource Document when the translation is complete:' + ss.getUrl();
MailApp.sendEmail(recipients, subject, body);
}
EDIT: I realized Im looking for the function to ignore all invalid emails (not just blank cells) and continue to run.