Skip to content

@jheitzeb /gist:1104924
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Google Docs Survey Emailer
function onFormSubmit(e) {
var to_email = "YOUREMAIL@YOURCOMPANY.COM";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var spreadsheet_name = ss.getName();
var sheet = ss.getSheets()[0];
var columns = sheet.getRange("A1:U1").getValues()[0];
var email_subject = "New response for [" + spreadsheet_name + "]";
var email_body = "Spreadsheet: " + spreadsheet_name + "\r\n\r\n";
var email_body_html = "<p><b>Spreadsheet: " + spreadsheet_name + "</b></p>";
for (var i = 0; i < columns.length; i++) {
var question = columns[i];
if (question != "") {
var answer = e.values[i];
email_body = email_body + question + "\r\n" + answer + "\r\n\r\n";
email_body_html = email_body_html + "<p><b>" + question + "</b><br/>" + answer + "</p>";
}
}
var optAdvancedArgs = {replyTo: to_email, htmlBody: email_body_html};
MailApp.sendEmail(to_email, email_subject, email_body, optAdvancedArgs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.