首页 > 解决方案 > 使用共享驱动器中的 Apps 脚本附加 PDF

问题描述

我需要使用 MailApp.sendEmail 将文件附加到邮件中 我遇到的问题是我无法从共享驱动器中附加任何内容,只能从个人驱动器中附加任何内容。我想使用共享驱动器来选择要附加的文件。

任何人都知道这是否可能?

更新:这是用于打开选择器的代码,目前仅适用于运行脚本的用户的个人驱动器:

function createPicker(token) {
  if (pickerApiLoaded && token) {
    var picker = new google.picker.PickerBuilder()
        // Instruct Picker to display all PDFs in Drive. For other
        // views, see https://developers.google.com/picker/docs/#otherviews
        .addView(google.picker.ViewId.PDFS)
        // Hide the navigation panel so that Picker fills more of the dialog.
        .enableFeature(google.picker.Feature.NAV_HIDDEN)
        // Hide the title bar since an Apps Script dialog already has a title.
        .hideTitleBar()
        .setOAuthToken(token)
        .setCallback(pickerCallback)
        .setOrigin(google.script.host.origin)
        // Instruct Picker to fill the dialog, minus 2 pixels for the border.
        .setSize(DIALOG_DIMENSIONS.width - 2,
            DIALOG_DIMENSIONS.height - 2)
        .build();
    picker.setVisible(true);
  } else {
    showError('Unable to load the file picker.');
  }
}

我想对此进行编辑,以便访问共享云端硬盘。我发现了一些使用 GDrive API 访问共享驱动器(也使用选择器)的东西,但我错过了成功编辑它的经验。

这就是我的意思:https ://developers.google.com/drive/api/v3/enable-shareddrives

标签: google-apps-scriptgoogle-drive-apigoogle-drive-shared-drive

解决方案


没关系,应该再搜索一些。很抱歉浪费您的时间,谢谢您的回答!

我使用的解决方案对我有用:

谷歌应用脚​​本,用于团队驱动的谷歌选择器


推荐阅读