Prevent email notification while adding a commenter in google appscript?

孤街浪徒 提交于 2019-12-25 04:43:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!