What is the correct syntax for emailing an image url in a row as an attachment?
I'm trying to loop through all rows within a Google Sheet and attach an image url as the image. I can send the correct subject line and message body using the below code (minus the attachment stuff below), but when I try and add the attachment stuff it doesn't let me save it and says "Missing : after property ID. (line 22, file "Code")" which is on the line that reads "attachments: attachment, blob]"
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2;
var numRows = sheet.getLastRow();
// Fetch the range of cells
var dataRange = sheet.getRange(startRow, 1, numRows, 2)
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = "[email protected]";
var subject = row[0];
var message = row[1].toString();
var attachment = UrlFetchApp.fetch(row[2]).getBlob();
MailApp.sendEmail(emailAddress, subject, message, {
name: 'Automatic Emailer Script',
attachments: attachment, blob]
});
} // for
} // sendEmails