Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 谷歌表单错误_Google Apps Script_Google Sheets_Google Forms - Fatal编程技术网

Google apps script 谷歌表单错误

Google apps script 谷歌表单错误,google-apps-script,google-sheets,google-forms,Google Apps Script,Google Sheets,Google Forms,我正在使用一个谷歌电子表格存储一个表单响应。它工作了一段时间,但刚刚退出,我现在收到电子邮件说我有这个错误: 找不到方法(类)(类)sendEmail(字符串、字符串、字符串、字符串、对象)。(第32行,文件“代码”) 电子表格中的第一列包含时间戳,然后数据就存储在时间戳之后。我已将代码粘贴到下面: function onFormSubmit(e) { var name = e.values[1]; var department = e.values[2]; var email

我正在使用一个谷歌电子表格存储一个表单响应。它工作了一段时间,但刚刚退出,我现在收到电子邮件说我有这个错误:

找不到方法(类)(类)sendEmail(字符串、字符串、字符串、字符串、对象)。(第32行,文件“代码”)

电子表格中的第一列包含时间戳,然后数据就存储在时间戳之后。我已将代码粘贴到下面:

function onFormSubmit(e) {
   var name = e.values[1];
   var department = e.values[2];
   var email = e.values[3];
   var phone = e.values[4];
   var project = e.values[5];
   var title = e.values[6];
   var description = e.values[7];
   var reach = e.values[8];
   var goal = e.values[9];
   var time = e.values[10];
   var work = e.values[11];


  // change this address to be the address where you want the notification to go 
   var to = "dreamsites.designs@gmail.com, nuwish4u@yahoo.com";
   var subject = "Intake Form Notification";
   var message = "Your Name: " + name + "\n \n";
       message += "Department: " + department + "\n \n";
       message += "Email: " + email + "\n \n";
       message += "Phone Number: " + phone + "\n \n";
       message += "Project title: " + title + "\n \n";
       message += "Project description: \n " + description + "\n \n";
       message += "Who are you trying to reach? \n" + reach + "\n \n";
       message += "Are you trying to achieve a specific goal with your communication efforts?  \n" + goal + "\n \n";
       message += "Is this request time sensitive? \n " + time + "\n \n";
       message += "Are you currently working with someone in Marketing & Communications?  \n" + work + "\n \n";
  var mailOptions = {
       name: name,
       replyTo: email,
   };
MailApp.sendEmail(to, subject, message, mailOptions);
}

我的触发器设置为OnFormSubmit>>从电子表格>>在表单提交时,我认为这是一个小的打字错误。能否删除
mailpoptions

var mailOptions = {
       name: name,
       replyTo: email //Removed comma
   };

你应该避免在互联网上暴露真实的电子邮件地址,即使在这里也是如此。谢谢你会尝试解决这个问题的。有时会有一些延迟,但至少现在可以工作了。谢谢。请注意,发生此错误的原因是因为在Javascript中创建
对象时,键/值对应该用逗号分隔:
var myObject={key1:val1,key2:val2}
。只需知道最后一个元素不应后跟逗号。您的
对象
从未被实例化,因为该输入错误导致Google Apps脚本显示您看到的错误。也许你现在知道了,也许不知道!