Я использовал несколько сценариев, которые нашел в Интернете, и столкнулся с той же проблемой. У меня есть несколько форм документов Google, которые мне нужны для получения отправленных данных по электронной почте (а не только уведомления о том, что форма была отправлена и соответствующая электронная таблица была обновлена). Этот скрипт БЫЛ работает, но по какой-то причине остановился:
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 = "Google Docs 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);
// By Amit Agarwal - www.labnol.org
}
На что я получаю сообщение об ошибке: TypeError: Cannot read property "namedValues" from undefined. (строка 20)
Я ничего не изменил, и теперь я не могу найти какой-либо сценарий отправки формы по электронной почте для работы. Кто-нибудь может помочь?