【发布时间】:2022-01-20 02:35:21
【问题描述】:
在 Apps Script 中,我目前正在以编程方式生成文件,通过 addEditor() 添加用户并自动向他们发送电子邮件。
我现在想做的是扩展它以包含一条消息。我认为这与这个绿色框相对应:
我在这里也发现了一个类似的问题,但一直无法正常工作:How to send a custom message when adding a viewer to Google Spreadsheet via Google Apps Scripts?
这是我目前所拥有的:
setPermission(documentId, email) {
// Get the document to set permissions on
const file = DriveApp.getFileById(documentId);
// Turn off sharing by editors
file.setShareableByEditors(false);
// Add the email to editors
file.addEditor(email);
}
如果我尝试做类似的事情:
...
file.addEditor(email, {emailMessage: 'Test'});
我收到以下错误:
Exception: The parameters (String,(class)) don't match the method signature for DriveApp.File.addEditor.
所以我很好奇:
- 这可行吗?
- 语法需要是什么?
【问题讨论】:
标签: google-apps-script google-sheets google-drive-api