What I want to achieve is that when the content of a certain cell in the spreadsheet is changed to a certain value, an automated mail should be sent.
First Try:
using the onEdit(e) function.
If I use this standard Google Script function I can access the event object e. The onEdit() function does not need an extra separate trigger.
However it is not allowed to send a mail with onEdit(). For security reasons the access to MailApp.sendEmail() is prohibited when the onEdit() fuction is used.
https://developers.google.com/apps-script/guides/triggers They cannot access services that require authorization. For example, a simple >trigger cannot send an email because the Gmail service requires authorization...
For this reason, I have declared a separate function. For example my MyEdit() function:
I created a trigger for this function. With the settings:
When the cell is changed, my MyEdit() is called, via the trigger but I cannot access the event object. For whatever reason. When accessing the object I always get error messages.
TypeError: Cannot read property 'setNote' of undefined at MyEdit(code:3:9)
The access to setNote is just an example. When I try to access different data on Event e I also get an error (i.e.:e.range.getRow();
I cannot found the root cause of this behaviour.
Maybe somebody has a solution!
Many thx in advance