我需要一个应用脚本来复制和通过电子邮件发送文件

时间:2019-04-15 13:42:39

标签: google-apps-script

我需要一个应用脚本,以在Google驱动器中复制文件夹以及其中的Google文档,然后将这些副本通过电子邮件发送给某人。我尝试查找一些零碎的代码来完成这项工作,但是我尝试的所有代码都没有奏效。

这是我之前想到的脚本

function myFunction() {{// make copy 
doc = DocumentApp.makeCopy('example');
}
                {                                                           
GmailApp.sendEmail("example_recipient@example.com", "test", "Just a test");
               }                                        
}

1 个答案:

答案 0 :(得分:0)

尝试一下:

function emailDrive() {
  var folder=DriveApp.getFolderById("id"); 
  var files=folder.getFilesByType(MimeType.GOOGLE_DOCS);
  var bA=[];
  while(files.hasNext()) {
    var file=files.next();
    bA.push(file.getBlob());
  }
  if(bA.length>0) {
    GmailApp.sendEmail('example_recipient@example.com','RE: files you requested', 'Please review and respond',{attachments:bA} )
  }
}