user2343022
user2343022

Reputation: 21

Google spreadsheet API, unable to send mail

if( row.toString() =="Others")   {

 sheet.msgBox("success");
   MailApp.sendEmail("[email protected]","hi","hi");


    }
    else
      sheet.msgBox("no");

using the above code i have been able to get a success alert, but im not able to send the mail , help required

Upvotes: 0

Views: 359

Answers (2)

Zig Mandel
Zig Mandel

Reputation: 19835

Dont name it onEdit, instead install it as a regular trigger. Then it runs with Owner permissions. However there are some restrictions of code from such triggers.

Upvotes: 2

eddyparkinson
eddyparkinson

Reputation: 3700

onEdit runs as the person editing the spreadsheet. ie. with the rights of the person editing the spreadsheet. And so would be unable to send an email.

  Google Calendar, Gmail, and Sites are not anonymous and the simple triggers cannot access those services.

See Understanding Triggers, here https://developers.google.com/apps-script/understanding_triggers

Work around: I think you can use UrlFetchApp.fetch and so you could create a web app as a workaround. i.e. call the web app using UrlFetchApp.fetch and have the web app send the email.

Upvotes: 0

Related Questions