Email 带有附件问题的电子邮件
我对这个脚本是一个完全的新手,所以我环顾四周,找到了一些满足我需要的脚本。我目前正在尝试自动发送每月新闻稿,但不断出现以下错误: 异常:无效参数:附件(第16行,文件“宏”) 代码如下: 函数sendEmails(){ 试试这个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
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'
});
// 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'
});