'Iterator has reached the end - trying to send an email
I'm getting a "Cannot retrieve the next object: iterator has reached the end. (file EmailAlertTEST.gs, line 194)" where L194 is 'MailApp.sendEmail(email,...' below.
I don't get it? Where's the iteration? This code just sends an email right?
Also, while i'm here. What does 'mccAccount' stand for exactly?
And, why is it called AdManagerApps? Where does the Apps come from? Is it short for Application? Makes no sense.
function sendEmail(account, alertTextArray, spreadsheet) {
var bodyText = '';
var adApprovalText = getTextAdsInAdGroup();
alertTextArray.forEach(function(alertText) {
// When zero alerts, this is an empty array, which we don't want to add.
if (alertText.length == 0) { return }
bodyText += alertText.join('\n') + '\n\n';
});
bodyText = bodyText.trim();
Logger.log(adApprovalText);
var email = spreadsheet.getRangeByName('email').getValue();
// if (bodyText.length > 0 && email && email.length > 0 && email != '[email protected]') {
// if (email && email.length > 0 && email != '[email protected]') {
Logger.log('Sending Email');
MailApp.sendEmail(email,
'MCCR Google Ads Account ' + account.getCustomerId() + ' Anomoly Alert.',
'Our account ' + account.getCustomerId() + ' / ' + account.getName() + ' can be checked: \n\n' +
bodyText + '\n\n' + adApprovalText + '\n\n' + 'Log into Google Ads and take a look: ' + 'ads.google.com\n\nAlerts dashboard: ' + SPREADSHEET_URL);
//}
//else if (bodyText.length == 0) {
//Logger.log('No alerts triggered. No email being sent.');
//}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
