gpt4 book ai didi

javascript - 发送带有附件的Google表格电子邮件ERROR

转载 作者:行者123 更新时间:2023-12-03 08:05:03 25 4
gpt4 key购买 nike

我想通过电子邮件发送附件,但出现错误

SyntaxError: Invalid or unexpected token (row 17, file "try.gs")


我不明白为什么?名为“i.pdf”的pdf在我的Google驱动器中
这是我的代码:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // Start at second row because the first row contains the data labels
var numRows = 3; // Put in here the number of rows you want to process

// Fetch the range of cells A3:E3
// Column A = Name, Column B = Email, Column C = Message, Column D = Message1, Column E = Message2
var dataRange = sheet.getRange(startRow, 1, numRows, 4)

// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[2]; // First column of selected data
var message = "Hey "; // Assemble the body text
var subject = "Sending emails from a Spreadsheet";
var file = DriveApp.getFilesByName(‘i.pdf’);
if (file.hasNext())
MailApp.sendEmail(emailAddress, subject, message, {
attachments: [file.next().getAs(MimeType.PDF)],
name: ‘Simple mail’});

}
}
有人可以帮我吗

最佳答案

该错误是由于使用打印/ curl /单引号= ‘’引起的。
用单引号或双引号字符''""代替它们。
有关

  • Notify via email when a cell is updated in google spreadsheet
  • Google AppScript syntax error for sendemail. Can't ID my problem
  • 关于javascript - 发送带有附件的Google表格电子邮件ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63457319/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com