google apps script - MailApp.sendEmail is not working properly -


i'm trying send notification using mailapp.sendemail on editing google spreadsheet (even on addition of new row or editing existing data)

here code wrote:

function onedit(e) {         var emailid = spreadsheetapp.getactivesheet().getrange(e.range.getlastrow(), 2, 1, 1).getvalues();     var desc = spreadsheetapp.getactivesheet().getrange(e.range.getlastrow(), 5, 1, 1).getvalues();     var guid = spreadsheetapp.getactivesheet().getrange(e.range.getlastrow(), 6, 1, 1).getvalues();     mailapp.sendemail(emailid, guid, guid);     // browser.msgbox(emailid + guid); } 

this code extracting edited data can see using browser.msgbox(emailid + guid); (but if placed before mailapp.sendemail , not if placed after mailapp.sendemail function). when use mailapp.sendemail function other function, executes , sending mails too. not in function.

any or pointers resolve this?

the special onedit() trigger function called simple trigger. check documentation here.

(simple triggers) cannot access services require authentication user. example, google translate service anonymous , can accessed simple triggers. google calendar, gmail, , sites not anonymous , simple triggers cannot access services.


Comments