我使用该方法通过邮件发送一些文件,但是我遇到了发送PDF文件的问题,他们没有反驳。
function sendEmail() {
var files = [
"1X0YYxxtnKJtkn9BhoBcSb265acOYOnWJytQeBKEvfqU",
"12r6Owm616Ioqj9EfOgkNqPgXNi88f_chdPRyBcSC2EM"
];
var attachments = [];
for (var f in files) {
var file = DriveApp.getFileById(files[f]);
attachments.push({
"type": file.getMimeType(),
"name": file.getName(),
"content": Utilities.base64Encode(file.getBlob().getAs('application/pdf').getBytes())
});
}
MailApp.sendEmail('mail@gmail.com', 'Attachment example', 'Two files are attached.', {
name: 'Automatic Emailer Script',
attachments: attachments
});
}