从Google云端硬盘使用Google Script发送多个附件

时间:2013-10-02 11:30:21

标签: javascript google-apps-script google-drive-api

您好我正试图通过脚本从我的谷歌驱动器发送多个图像,但代码似乎不起作用。我怎样才能做到这一点?

function sendEmail() {

    var Rainfall = DriveApp.getFilesByName('beach.jpg')
    var High     = DriveApp.getFilesByName('High.png')

    MailApp.sendEmail({
    to:"example@google.com", 
    subject: "Images for Social Media", 
    body:"Hi Joe, here are the images for Social Media",


    attachments: [Rainfall.next(),High.next()]



  })

}

1 个答案:

答案 0 :(得分:2)

最后得到了Google App Script编辑器。 这个变体defenitly工作,并给我发送电子邮件与两个attacments

function sendEmail() {

var Rainfall = DriveApp.getFilesByName('Untitled document')
var Rainfall2 = DriveApp.getFilesByName('128x128_tl_icon.png')

MailApp.sendEmail({
to:"mymail@gmail.com", 
subject: "Images for Social Media", 
body:"Hi Joe, here are the images for Social Media",


attachments: [Rainfall.next(), Rainfall2.next()]
  })

}
sendEmail()

确保您的Google云端硬盘中存在“无标题文档”和“128x128_tl_icon.png”文件。它认为这是你的问题