Not allowed to execute sendEmail() from custom function, but OK in script editor

前端 未结 1 1104
逝去的感伤
逝去的感伤 2020-12-02 02:27

I have been trying to find a way to send single row of data to a specific email address in a \"live/running\" spreadsheet that I am using within my domain, to keep track of

相关标签:
1条回答
  • 2020-12-02 02:48

    Read over Permissions and Custom Functions. Since custom functions (scripts called from spreadsheet functions) are open to any user of a spreadsheet, they aren't allowed to use any service that requires authentication. That's why you can't send mail from one.

    This is different than the process of Authorizing a script to access your services. That does make the error message confusing, but rest assured that was just about the way you were invoking the script.

    No problem though, because a custom function is a bad way to perform this type of action anyway, because the function will be re-evaluated every time there is a change in the spreadsheet, sending many more emails than you want.

    I recommend that you create a menu item for this operation instead. (See the sample code provided in the editor if you create a new Spreadsheet script.) The workflow would be to move the cursor to the row you want processed, then use the menu to "Make It So", which would invoke your script.

    0 讨论(0)
提交回复
热议问题