Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
How to get file ID to send mails from GoogleSheets/Script

I'm new to coding and i'm having issues with a code where i keep getting "Error Syntaxis: Missing ) after argument

This is my current code:

    function myFunction(){
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet('Form Responses 1');
  const url = sheet.getRange().getValues();
  url.forEach(function(row,index){
    if (index === 0) return;
    if (row[19]) return;
  const idFile = url.match(/[-w]{25,}/);
  const file = DriveApp.getFileById(idFile)
  const blob = file.getAs(MimeType.PDF)

  var message = 'Thanks for your interest this will be the first step'
  var mail = row[2]
  var team = row[8]
GmailApp.sendEmail(mail,team,"Subject",message,{attachments: [blob]})

This is my second script, the first one i built it to create PDF for each new google form entry and in column 19 the PDF link is written. The idea is that after that PDF linked is created it takes the file ID and then sends it automatically to the person that filled the form with CC to my team if there is no link created then it should not send it.

But i have researched and i honestly don't know much to identify my error, i hope anyone can help me i would appreciate it. Either not by giving the answer but help in any form would be appreciated!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Missing parenthesis after the arrow function see comment below

function myFunction() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet('Form Responses 1');
  const url = sheet.getRange().getValues();
  url.forEach(function (row, index) {
    if (index === 0) return;
    if (row[19]) return;
    const idFile = url.match(/[-w]{25,}/);
    const file = DriveApp.getFileById(idFile)
    const blob = file.getAs(MimeType.PDF)

    var message = 'Thanks for your interest this will be the first step'
    var mail = row[2]
    var team = row[8]
    GmailApp.sendEmail(mail, team, "Subject", message, { attachments: [blob] })
  });//your missing the parenthesis here after the arrow function
 }
about 4 years ago · Juan Pablo Isaza Report

0

You're missing several closing brackets and parenthesis.

function myFunction(){
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet('Form Responses 1');
    const url = sheet.getRange().getValues();
    url.forEach(function(row,index){
        if (index === 0) return;
        if (row[19]) return;
        const idFile = url.match(/[-w]{25,}/);
        const file = DriveApp.getFileById(idFile);
        const blob = file.getAs(MimeType.PDF);

        var message = 'Thanks for your interest this will be the first step';
        var mail = row[2];
        var team = row[8];
        GmailApp.sendEmail(mail,team,"Subject",message,{attachments: [blob]});
    });
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!