I'm trying to send a notification using MailApp.sendEmail on editing a google spreadsheet (even on addition of new row or editing existing data)
Here is the code I 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 is extracting the edited data which I can see using Browser.msgBox(emailId + guid); (but only if placed before the MailApp.sendEmail and not if placed after MailApp.sendEmail function). When I use MailApp.sendEmail function with some other function, it executes well and is sending the mails too. But not in this function.
Any help or pointers to resolve this?