在谷歌appscript中添加评论者时阻止电子邮件通知?
问题描述:
我正在使用google appscript使用 addCommenter
函数添加评论者。但它会向用户发送邀请。有什么方法可以禁用此电子邮件通知?
I am adding commenter using google appscript using addCommenter
function. But it sends invitation to the user. Is there any way to disable this email notification??
这是我的代码
Here is my code
function shareGroup(usersToShare, sheetId) {
var newFile =DriveApp.getFileById(sheetId);
for (var i = 0; i <= usersToShare.length - 1; i++) {
newFile.addCommenter(usersToShare[i]);
}
}
答
这是使用默认DriveApp服务不可能的。不过,您可以使用高级云端硬盘服务解决此问题(您应通过选择资源>高级Google服务在脚本编辑器中启用 ...然后在Google Developers Console中启用它。)
This isn't possible using the default DriveApp Service. However, you can use the Advanced Drive Service to workaround around this issue (which you should enable in the Script Editor by selecting Resources > Advanced Google services... and then enabled it in the Google Developers Console.)
使用的代码应该是:
The code used should be:
Drive.Permissions.insert(
{
'role': 'reader',
'type': 'user',
'value': 'jane.doe@example.com',
'additionalRoles': ['commenter']
},
'fileId',
{
'sendNotificationEmails': 'false'
});