r/GoogleAppsScript • u/JustPhocus • Mar 18 '19
Send email automatically from spreadsheet
Hi, I am just figuring out about Google app script and would like some help with setting up a trigger that automatically sends and email notification once a cell in a column is edited. For example, Column B has the email addresses in it and Column K is going to be edited. I need to have an email sent to the email address in column B once column K gets edited. and the email has to say something along the lines of "your status has been updated". I was wondering if this was possible. Any help at all would be very appreciated.
6
Upvotes
1
u/JustPhocus Mar 26 '19
So I found this code below and I am not sure on how to edit it so it fits my spread sheet.
function sendEmail(e) {
if (e.source.getActiveSheet().getName() !== 'testing2' || e.range.columnStart !== 2 || e.range.rowStart == 1) return;
var r = e.range.offset(0, -1, 1, 3).getValues()[0];
MailApp.sendEmail(r[2], "Status update", "Title " + r[0] + "status update:" + r[1])
}
For example, Say I have the email address in column B and the cells that get edited are in Column K. Once a cell in column K gets edited I want an email sent out to the email address that is in column B. The email address would be in the same row as the cell that gets edited.
Also an additional question is I only want it to do this for one sheet in the spreadsheet not all of the sheets.