-2
我试图在提交表单并将信息填入电子表格时收到一封电子邮件。昨天的工作,但自那以后所有我得到的是一个错误电子邮件脚本不能正常工作
7/13/14 5:23 PM sendFormByEmail TypeError: Cannot call method "toString" of undefined. (line 20, file "Email Script") formSubmit
function sendFormByEmail(e)
{
// Remember to replace XYZ with your own email address
var email = "[email protected]";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
var subject = "PC Repair Ticket";
// 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
// http://youtu.be/z6klwUxRwQI
// By Amit Agarwal - www.labnol.org
}