我是編碼新手,我遇到了代碼問題,我在引數后不斷收到“錯誤語法:缺失)”
這是我當前的代碼:
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]})
這是我的第二個腳本,我構建的第一個腳本是為每個新的 google 表單條目創建 PDF,并且在第 19 列中寫入了 PDF 鏈接。這個想法是,在創建 PDF 鏈接后,它會獲取檔案 ID,然后將其自動發送給使用 CC 填寫表單的人,如果沒有創建鏈接,則不應發送它。
但我已經研究過,老實說,我對確定我的錯誤知之甚少,我希望任何人都可以幫助我,我將不勝感激。要么不通過給出答案,而是以任何形式提供幫助,將不勝感激!
uj5u.com熱心網友回復:
箭頭函式后缺少括號,請參閱下面的評論
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
}
uj5u.com熱心網友回復:
您缺少幾個右括號和圓括號。
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]});
});
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/357856.html
標籤:javascript 谷歌应用程序脚本 谷歌表格 电子邮件附件 脚本
