Created
October 5, 2015 17:23
-
-
Save postphotos/1a8fc797ff02cba2a869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendFormByEmail(e) | |
{ | |
// Remember to replace this email address with your own email address | |
var email = "dev@relativityschool.org"; | |
var s = SpreadsheetApp.getActiveSheet(); | |
var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0]; | |
var message = ""; | |
var subject = "EQUIPMENT REQUEST - "; | |
// This prepends the email with whatever you wnat to call it. | |
// The variable e holds all the form values in an array. | |
// Loop through the array and append values to the body. | |
for(var i in headers) | |
message += headers[i] + ': '+ e.namedValues[headers[i]].toString() + "\n\n"; | |
// this will bring the WHOLE kit and caboodle into the email. | |
// Insert variables from the spreadsheet into the subject. | |
// In this case, I wanted the new hire's name and start date as part of the email subject. | |
// In Excel/Google Sheets you can write an offset reference. I use {=(COLUMN()-1)} to determine what I'm writing. | |
subject += e.namedValues[headers[15]].toString() + " - Submitted at " + e.namedValues[headers[0]].toString() + " by " + e.namedValues[headers[11]].toString() + " (" + e.namedValues[headers[69]].toString() + ") - desired checkout " + e.namedValues[headers[12]].toString(); | |
// Funtion to send email | |
MailApp.sendEmail(email, subject, message); | |
// Based off of a script originally posted by Amit Agarwal - www.labnol.org | |
// Credit to Henrique Abreu for fixing the sort order | |
// Credit to Leo, PostPhotos, for clarifying the columns | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment