Google Form Script Error

TypeError: Cannot read property “namedValues” from undefined. (line 20, file “Code”)

Here’s the script. It’s been running great for over a year, but just recently stopped working.

function sendFormByEmail(e)
// Remember to replace XYZ with your own email address
var email = “,”;

// Optional but change the following variable
// to have a custom subject for Google Docs emails
var subject = “Funley’s Sample Form Submitted”;

// The variable e holds all the form values in an array.
// Loop through the array and append values to the body.

var s = SpreadsheetApp.getActiveSheet();
var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = “”;

// Credit to Henrique Abreu for fixing the sort order

for(var i in headers)
message += headers[i] + ‘ = ‘+ e.namedValues[headers[i]].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);

// Watch the following video for details

// By Amit Agarwal –