mercredi 25 février 2015

Google Form not emailing when changing subject variable

I'm pretty new to Google scripting or scripting in general. I used the following to send the information input by the user into one email to a specific email address. what I wanted to do was to have it take the 3rd row as the subject line (in this case it's the name). This is the script I have in the spreadsheet the Form is linked to:



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 = "dyingkingdomsrecords@gmail.com";
var subject = row[3];
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());
}

}


When I don't have a subject variable or put in a string for it I get the email no problem. I'm sure I'm missing something obvious. Thank you so much for any help.


Aucun commentaire:

Enregistrer un commentaire