问题
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]);
}
}
回答1:
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'
});
来源:https://stackoverflow.com/questions/38611334/prevent-email-notification-while-adding-a-commenter-in-google-appscript