Skip to content

Instantly share code, notes, and snippets.

@labnol
Created February 25, 2012 08:36
Show Gist options
  • Save labnol/1907354 to your computer and use it in GitHub Desktop.
Save labnol/1907354 to your computer and use it in GitHub Desktop.
Google Apps Script for forms in Google Docs
/* Google Apps Script for adding Email Notifications to Google Docs */
/* For video and implementation, go to http://labnol.org/?p=20884 */
function sendFormByEmail(e)
{
// Remember to replace XYZ with your own email address
// Also, don't miss the semicolon
var email = "XYZ";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
var subject = "Google Docs Form Submitted";
// The variable e holds all the form values in an array.
// Loop through the array and append values to the body.
var message = "";
for(var field in e.namedValues) {
message += field + ' :: ' + e.namedValues[field].toString() + "\n\n";
}
// This is the MailApp service of Google Apps Script
// that sends the email. You can also use GmailApp here.
MailApp.sendEmail(email, subject, message);
// Video Screencast - http://youtu.be/z6klwUxRwQI
// By Amit Agarwal - www.labnol.org
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment