问题描述
我正在 Apps Script 中创建一个工作流程,其中从模板生成文档并与各种用户共享以供批准.该脚本会发送一封定制的电子邮件,通知用户该文档需要他们的批准,但他们还会在流程的每个阶段收到第二封电子邮件,该电子邮件来自存储该文档的驱动器的用户,其中说用户已与您共享文档".有没有办法禁用这些警报?当您从云端硬盘手动共享文档时,有一个复选框选项可让您选择用户是否收到通知.但是,我找不到使用 Apps 脚本禁用此通知的方法.
I am creating a workflow process in Apps Script where a Doc is generated from a template and shared with various users for approval. The Script sends a customised email notifying a user that the document requires their approval but they also receive a second email at each stage in the process from the user whose Drive the document is stored in saying "User has shared a document with you". Is there any way of disabling these alerts? When you share a document manually from your Drive, there is a checkbox option that allows you to choose whether or not the user receives a notification. However, I cannot find a way to disable this notification with Apps Script.
我正在使用 doc.addEditors(users)
来共享文档.
I am using doc.addEditors(users)
to share the document.
非常感谢
推荐答案
如果您使用 Google Docs 或 Google SpreadSheets,有一个简单的解决方案.您可以使用 DocumentApp 或 SpreadSheetApp 共享您的文档或电子表格,而无需电子邮件通知:
There is a simple solution if you are working with Google Docs or Google SpreadSheets. You can use DocumentApp or SpreadSheetApp to share your Docs or SpreadSheets without email notification:
DocumentApp
var doc = DocumentApp.openById('124144')
doc.addEditor('example@mail.com').addViewer('example2@mail.com')
电子表格应用程序
var spreadSheet = SpreadsheetApp.openById('124144')
spreadSheet.addEditor('example@mail.com').addViewer('example2@mail.com')
但是,如果您使用的文档不是 Docs 或 SpreadSheets,则必须使用 DriveApp 进行共享,并且将发送电子邮件通知.
However, if you are working with documents that aren't Docs or SpreadSheets, you must share then using DriveApp and email notification will be send.
这篇关于使用 Google Apps 脚本在不通知用户的情况下共享云端硬盘文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!