Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2019 09:46
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Send HTML email from Google Apps Script. Full article here:
function onOpen()
var ui = SpreadsheetApp.getUi();
.addItem('Approve', 'doApprove')
function doApprove()
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
var row = cell.getRow();
var candidate = getCandidateFromRow(row);
var ui = SpreadsheetApp.getUi();
var response = ui.alert('Approve ''?', ui.ButtonSet.YES_NO);
if(response == ui.Button.YES)
handleApproval(row, candidate);
function getCandidateFromRow(row)
var values = SpreadsheetApp.getActiveSheet().getRange(row, 1,row,3).getValues();
var rec = values[0];
var candidate =
first_name: rec[0],
last_name : rec[1],
email: rec[2]
}; = candidate.first_name+' '+candidate.last_name;
return candidate;
function handleApproval(row, candidate)
var templ = HtmlService
templ.candidate = candidate;
var message = templ.evaluate().getContent();
subject: "Your application is approved!",
htmlBody: message
SpreadsheetApp.getActiveSheet().getRange(row, 4).setValue('approved');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment