0

I've got an empty Google Spreadsheet and the following working Apps Script code:

// This function SUCCESSFULLY opens a message box whenever a cell is edited, it shows the row of the edited cell.
function onEdit(e) {
  Browser.msgBox(e.range.getRow());
}

// This function SUCCESSFULLY sends an email to 'john@doe.com' (this email address is changed for an actual registered address) upon being called.
function myTestFunction() {
  MailApp.sendEmail('john@doe.com', 'Test', 'Cell changed');
}

However, if I change the 'onEdit'-function to the following it doesn't work properly:

// This function SUCCESSFULLY opens a message box whenever a cell is edited, BUT IT DOES NOT SEND AN EMAIL.
function onEdit(e) {
  Browser.msgBox(e.range.getRow());
  MailApp.sendEmail('info@bpbl.de', 'Test', 'Cell changed');
}

Why does the latter 'onEdit'-function NOT send an email?

(Yes, I have checked my remaining daily email quota, there is plenty left.)

nik257
  • 1
  • Does this answer your question? [How to use onEdit function to trigger an email](https://stackoverflow.com/questions/67078373/how-to-use-onedit-function-to-trigger-an-email) – Nikko J. May 06 '21 at 16:22

1 Answers1

0

This question has already been posted, and unfortunatly, you can't call the sendEmail function inside the simple trigger onEdit :(

Google-apps-script will not send email inside an onEdit function

https://developers.google.com/apps-script/guides/triggers

Waxim Corp
  • 657
  • 4
  • 16