This is my script

function sendEmails() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2;  // First row of data to process
  var numRows = 8;   // Number of rows to process
  // Fetch the range of cells A2:B3
  var dataRange = sheet.getRange(startRow, 1, numRows, 2)
  // Fetch values for each row in the Range.
  var file = DriveApp.getFilesByName('Thomas.pdf')
  var data = dataRange.getValues();
  for (i in data) {

    var row = data[i];
    var emailAddress = row[0];  // First column
    var message = row[1];       // Second column
    var subject = "Sending emails from a Spreadsheet";
    MailApp.sendEmail(emailAddress, subject, message,
       {attachments: file.next().getBlob()};

I keep getting the Error: Missing ) after argument list. (line 17, file "SendEmail") Can anybody see whats the error is, or guide me in right direction?

  • Mhh just look for the closing ) for MailApp.sendEmail( – bummi Dec 18 '18 at 10:41

The solution is quite straightforward: add the missing ).


MailApp.sendEmail(emailAddress, subject, message,
       {attachments: file.next().getBlob()};


   emailAddress, subject, message,
   {attachments: file.next().getBlob()}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.