Manage Google Apps Script execution failure notifications for triggers

◇◆丶佛笑我妖孽 提交于 2019-12-06 06:54:27

问题


Is it possible to manage failure notification for triggers in Google Apps Script via script code? I know that it is possible from Google Apps Script console, but I want to remove notification via function in my code, where I add time based triggers. Or is there any other way to remove this kind of notification?


回答1:


The answer is no, unfortunately. The only way to manage these notification emails is via the UI. You can check the documentation here: https://developers.google.com/apps-script/reference/script/

If you want to control the failure notifications more closely, one possible workaround would be to turn off Google's notifications, and then make your own. You could use either error catching statements or some other method to identify when your script has failed, and then use the GmailApp class of the Gmail service to send notifications according to whatever rules you like.

But it sounds like your real problem is that you don't want to have to manually turn off all these notifications via the UI when programmatically adding triggers. Here's a hacky solution: when you add this trigger, also add a feature that deletes the failure notification emails received for this script. You can use the Gmail service to do that.



来源:https://stackoverflow.com/questions/19836765/manage-google-apps-script-execution-failure-notifications-for-triggers

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