Step 1: Launch Google Drive
Step 2: Create a Google form
All entries from this form will go to a google spreadsheet
Step 3: Go to the spreadsheet where form entries will populate and click tools -> script editor. Choose to create new script. Paste script from below into the provided area. Save.
Step 4: From within the area you created the script choose: Resources -> Triggers -> Add new trigger. Choose “SendGoogleFormViaEmail” from the run column. The other options are self explanatory. This trigger will send you an email with the form fills each time the form is updated.
[code]
function Initialize() {
var triggers = ScriptApp.getScriptTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendGoogleFormViaEmail")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
function SendGoogleFormViaEmail(e)
{
try
{
// You may replace this with another email address: var email = "yourmail@domain.com";
var email = Session.getActiveUser().getEmail();
// change the below var to the desired subject
var subject = "Google Docs Form Via Email";
var s = SpreadsheetApp.getActiveSheet();
var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = "";
// Only include form fields that are not blank
for ( var keys in columns ) {
var key = columns[keys];
if ( e.namedValues[key] && (e.namedValues[key] != "") ) {
message += key + ‘ :: ‘+ e.namedValues[key] + "\n\n";
}
}
// This is the MailApp service of Google Apps Script
MailApp.sendEmail(email, subject, message);
} catch (e) {
Logger.log(e.toString());
}
}[/code]