Reputation: 25
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
if( sheet.getSheetName() != 'Sheet1' ) {
return 0;
}
var selectedCell = ss.getActiveCell();
if( selectedCell.getColumn() == 1) {
var dateTimeCell = selectedCell.offset(0, 2);
dateTimeCell.setValue('auto');
GmailApp.sendEmail('[email protected]', selectedCell.getRow(), 'hello')
}
if I modify column A and run script, Gmail sent. but if I modify column A only (don't run code), then Gmail not sent. 'auto' is inserted in both case. I suspect only GmailApp.sendEmail is not working.
why?
Upvotes: 1
Views: 52
Reputation: 35
Vytautas is right. It says that:
They cannot access services that require authorization. For example, a simple trigger cannot send an email because the Gmail service requires authorization, but a simple trigger can translate a phrase with the Language service, which is anonymous.
Upvotes: 0
Reputation: 2286
Do you have a trigger set up for it? The function you have only shows a simple trigger onEdit()
which cannot send emails. See Restrictions here.
Upvotes: 2