Skip to content

Instantly share code, notes, and snippets.

@vncloudsco
Created December 3, 2018 03:05
Show Gist options
  • Save vncloudsco/8d7034e273909c3f6a5e75a828083f32 to your computer and use it in GitHub Desktop.
Save vncloudsco/8d7034e273909c3f6a5e75a828083f32 to your computer and use it in GitHub Desktop.
function Initialize() {
var triggers = ScriptApp.getProjectTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendGoogleForm")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
function SendGoogleForm(e)
{
try
{
// You may replace this with another email address
var email = "hotro@vnclouds.co";
// Optional but change the following variable
// to have a custom subject for Google Form email notifications
var subject = "Thông Tin Khách Hàng Đăng Ký Gói Free";
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
// that sends the email. You can also use GmailApp for HTML Mail.
MailApp.sendEmail(email, subject, message);
} catch (e) {
Logger.log(e.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment