0
votes

I have a spreadsheet with a menu that has one item "Modify", which is bound to a function that modifies a cell in the active sheet:

SpreadsheetApp.getActiveSheet().getRange("A1").setValue(new Date().toString()) 

How to get an e-mail notification once this menu item is triggered. I could get email notifications when the spreadsheet is modified manually. I tried the onEdit function like this:

function onEdit(e){
   MailApp.sendEmail("[email protected]", "Test Modify", "Hello!")
}

and also tried using a trigger that fires a function like this:

function alert(e){
   MailApp.sendEmail("[email protected]", "Test Modify", "Hello!")
}

and I still receive no notifications

1

1 Answers

0
votes

You don't need any triggers for this: just insert the email-sending command into the function that does the modification.

SpreadsheetApp.getActiveSheet().getRange("A1").setValue(new Date().toString())
MailApp.sendEmail("[email protected]", "Test Modify", "Hello!")

By the way, simple triggers like function onEdit() run in no-authorization mode, hence cannot send emails. Only installable triggers can send emails.