Email 带有附件问题的电子邮件

Email 带有附件问题的电子邮件,email,google-apps-script,google-drive-api,email-attachments,Email,Google Apps Script,Google Drive Api,Email Attachments,我对这个脚本是一个完全的新手,所以我环顾四周,找到了一些满足我需要的脚本。我目前正在尝试自动发送每月新闻稿,但不断出现以下错误: 异常:无效参数:附件(第16行,文件“宏”) 代码如下: 函数sendEmails(){ 试试这个 MailApp.sendEmail(emailAddress, subject, message, {attachments:[file.getAs(MimeType.PDF)] }); 试试这个 MailApp.sendEmail(emailAddress, sub

我对这个脚本是一个完全的新手,所以我环顾四周,找到了一些满足我需要的脚本。我目前正在尝试自动发送每月新闻稿,但不断出现以下错误:

异常:无效参数:附件(第16行,文件“宏”)

代码如下:

函数sendEmails(){

试试这个

MailApp.sendEmail(emailAddress, subject, message, {attachments:[file.getAs(MimeType.PDF)] });
试试这个

MailApp.sendEmail(emailAddress, subject, message, {attachments:[file.getAs(MimeType.PDF)] });

根据文档,使用MailApp时,您不能发送带有附件的电子邮件。相反,您需要使用GmailApp

下面是使用GmailApp获得解决方案的示例:

 // Send an email with a file from Google Drive attached as a PDF.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');

GmailApp.sendEmail('mike@example.com', 'Attachment example', 'Please see the attached file.', {
    attachments: [file.getAs(MimeType.PDF)],
    name: 'Automatic Emailer Script'
});

根据文档,在使用MailApp时,您不能发送带有附件的电子邮件。相反,您需要使用GmailApp

下面是使用GmailApp获得解决方案的示例:

 // Send an email with a file from Google Drive attached as a PDF.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');

GmailApp.sendEmail('mike@example.com', 'Attachment example', 'Please see the attached file.', {
    attachments: [file.getAs(MimeType.PDF)],
    name: 'Automatic Emailer Script'
});

错误在第16行,但没有第16行…更新您的代码错误在第16行,但没有第16行…更新您的代码很高兴它能工作。请在答案上打勾,以便其他人能看到并解决此问题。很高兴它能工作。请在答案上打勾,以便解决此问题并使o可见瑟斯。