I have a spreadsheet where data will be continuously inputted (through Google Forms and user input), and I would like to have code that will send out a single email for a single row, which I can call multiple times as rows get completed. Currently, I created a custom function that is supposed to do this but when I run it I get an error which reads "You do not have permission to call MailApp.sendEmail. Required permissions: https://www.googleapis.com/auth/script.send_mail (line 6)."
function sendDirectiveResponse(name, message, response, emailAddress) {
var sheet = SpreadsheetApp.getActiveSheet();
var emailSent = "Email Sent";
var message = "Received: " + message + "\n\n Response: " + response;
var subject = "Message Response";
MailApp.sendEmail(emailAddress, subject, message);
return emailSent
}
I expect an email to be sent out and the cell to show "Email Sent" but, instead, it says "#ERROR" and no email is sent.