Manage Google Apps Script execution failure notifi

2019-04-11 00:50发布

问题:

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.