将Google文档转换为pdf并发送到电子邮件地址

时间:2015-07-14 17:27:40

标签: google-apps-script

我不知道如何做到这一点。但我需要一个脚本将某个Google文档转换为PDF,然后将电子邮件(带有该PDF作为附件)发送到某个电子邮件地址。

有人可以帮忙吗?

非常感谢!

1 个答案:

答案 0 :(得分:1)

请参阅此处描述的内容:https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

// 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'
 });