email - 设置脚本以在电子邮件通知中包含 google docs 表单数据

标签 email google-apps-script google-docs google-forms

我已经使用 googledocs 设置了一个表单。我只想将实际数据输入到通过电子邮件发送给我的表单中,而不是一般的回复建议表单已完成。

我没有代码等方面的技能或经验,但我确信我可以解决这个问题。我已经花了几个小时,但没有任何运气。

我的表单非常基本。它有 5 个字段。其中 4 个只是文本回复,还有一个多项选择。

我在网上找到了这个 tute (http://www.labnol.org/internet/google-docs-email-form/20884/),我认为它总结了我正在尝试做的事情,但无法得到它上类。

从这个网站我输入了以下代码:

function sendFormByEmail(e) 
{    
  var email = "reports.mckeir@gmail.com"; 

  var subject = "Google Docs Form Submitted";  

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

 for(var i in headers)
message += headers[i] + ' = '+ e.namedValues[headers[i]].toString() + "\n\n"; 

  MailApp.sendEmail(email, subject, message); 
}

对此,我得到以下回应:->

Your script, Contact Us Form Mailer, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.



该脚本由文档 100% Club 使用。

细节:
Start               Function        Error Message                                                       Trigger     End
12/3/12 11:06 PM    sendFormByEmail TypeError: Cannot call method "toString" of undefined. (line 12)    formSubmit  12/3/12 11:06 PM

有没有人能帮我解释一下?我猜我没有包括一些需要的数据,但老实说我不知道​​。

最佳答案

解决方法 http://www.labnol.org/internet/google-docs-email-form/20884/
您必须设置应用程序脚本才能将数据作为电子邮件转发。

关于email - 设置脚本以在电子邮件通知中包含 google docs 表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13683060/

相关文章:

Codeigniter 如何为电子邮件创建 html 模板

javascript - 谷歌脚本中的内容持久性 "blob"

html - 包含嵌入/发布的 Google 文档的 Iframe 的自动高度

google-apps-script - 使用 Apps 脚本获取文档的审批流程版本名称/编号

html - 如何使表格数据在电子邮件中响应

email - 命令顺序错误。服务器响应是 : This mail server requires authentication when attempting to send to a non-local e-mail

email - 在 mailchimp 模板中使用 typekit

javascript - Spotify API - 在 Google Apps 脚本中检索有效的访问 token

javascript - 使用 Google Calendar API 删除事件

filter - SUMIF与Google Spreadsheet中的FILTER函数一起使用