Skip to content

Instantly share code, notes, and snippets.

@matticusfinch
Last active May 9, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matticusfinch/1459cbd8bf0aa053c1ff0c4fc6f73ecc to your computer and use it in GitHub Desktop.
Save matticusfinch/1459cbd8bf0aa053c1ff0c4fc6f73ecc to your computer and use it in GitHub Desktop.
function sendFormByEmail(e)
{
var email = "webforms@safetysync.com";
var subject = 0;
var doc = SpreadsheetApp.getActiveSpreadsheet();
subject = doc.getName();
var message = "*contents*<p><b><u>" + subject + "</u></b></p><br>";
var s = SpreadsheetApp.getActive().getSheetByName("Form responses 1");
var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
for(var i in headers) {
if(headers[i]!=null && e!=null)
message += "<p><b>" + headers[i].toString() + "</b><br>"
+ e.namedValues[headers[i]].toString() + "</p>";
}
MailApp.sendEmail(email, subject, "", {htmlBody: message});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment