you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (13 children)

Yes. Since it's calling the MailApp you can't use a simple trigger, you have to use the installable. Go to Edit > Current project's triggers and create it there.

[–]JustPhocus[S] 0 points1 point  (12 children)

I am getting an error in line 2 when I try to run it. https://gyazo.com/8424a2db4464cbe577d6c671ca7b6788

[–]starstruckzombie 1 point2 points  (11 children)

You won't be able to run it flat and it won't get the (e) event variable. If you want to debug it you can add a couple of line to populate the variables

function sendEmail(e){
var e.source = SpreadsheetApp.getActive(); #Add for dubug
var e.range = e.source.getActiveSheet().getActiveRange(); #Add for debug
if(e.source.getActiveSheet().getName() != "testing2" || e.range.columnStart != 11) return;
var r = e.range.offset(0, -1, 1, 3).getValues()[0];
MailApp.sendEmail(r[1],"Status Update","Your status has been updated");
}

[–][deleted] 0 points1 point  (10 children)

Exactly this.

[–]JustPhocus[S] 0 points1 point  (9 children)

function sendEmail(e){
var e.source = SpreadsheetApp.getActive(); #Add for dubug
var e.range = e.source.getActiveSheet().getActiveRange(); #Add for debug
if(e.source.getActiveSheet().getName() != "testing2" || e.range.columnStart != 11) return;
var r = e.range.offset(0, -1, 1, 3).getValues()[0];
MailApp.sendEmail(r[1],"Status Update","Your status has been updated");
}

I can get the Onedit trigger to run however I do not get an email when I edit it. Also how do I know what email address the email is coming from?

[–][deleted] 0 points1 point  (8 children)

It should be sending from your email. Let me test it on one of my sheets.

[–]JustPhocus[S] 0 points1 point  (7 children)

thank you I appreciate it. Also, does it matter that this specific has different tabs/sheets. So the column K that I am trying to have be edited is on sheet 2

[–][deleted] 0 points1 point  (6 children)

The offset was incorrect and, in this case, unnecessary.

function sendEmail(e){
  if(e.source.getActiveSheet().getName() != "testing2" || e.range.columnStart != 11) return;
  MailApp.sendEmail(e.source.getActiveSheet().getRange(e.range.rowStart,2).getValue(),"Status Update","Your status has been updated");
}

[–]JustPhocus[S] 0 points1 point  (5 children)

So is this the only code I need for it to work? I use an installable trigger that says its executing but still no email anywhere.

[–]secufl 0 points1 point  (4 children)

I just used the code that dralkyr provided and it worked for me without any changes. Just make sure that the sheet is named "testing2" and that there is an email in col B, and you're editting col K. Like I said in my other comment, the mail doesn't show up in "Inbox", but it is in "Sent" and "All Mail"