繁体   English   中英

在 Email 消息中获取 Google Forms 响应

[英]Get Google Forms Responses in an Email Message

我写信给您是因为我遇到了基于 Google 表单提交(或发送 GForm 时的新 GSheet 条目)的自动 email 脚本的问题。 流程简述:

我有一个链接到 Data Studio 和 Power BI 仪表板的 Google 表单( 这里有一个类似的表单)。 根据进入电子表格的数据,forms 会自动使用破折号中的计算字段(日期、ActionID、代码、ID、位置等)进行预填充,并且数据会进入破折号链接的电子表格[可能看起来像的示例] . 问题是,如果在检查过程中发现错误,表格/电子邮件的副本也应发送给员工(可选,比他们高的人,以便双方都知道详细信息,而不仅仅是填写的审计员-在表格中 – 只是选项)。 由于数据的敏感性,我无法使用任何可用的 GForms 附加组件。 审计员没有对 Forms/Dashes 的编辑权限,并且通过 email 发送所有信息会花费太长时间。 我还创建了一个测试 Google 表单来演示它的外观 总而言之,我正在寻找的是一个动态脚本,它还将获取员工的公司 email(主管是可选的),当审计员提交表格时,表格的电子邮件/副本也会发送到上述人员。 我找不到任何与 GForms 相关的内容。

我以前使用过类似的脚本,但不要认为它是基于添加到电子表格[Example]的新行。 如果不可能实现这样的目标,即使是电子表格输入表格/电子邮件也会非常感激(基于表格中的“EmployeeEmail”的电子邮件+包括选定的列,如表中所示),尽管我担心事情会出错在一个有很多行的文件中。 我试图找到类似的东西并发现了 2 个脚本,但我不知道如何使它们动态化:下面的第一个只是将消息发送到给定范围内的电子邮件,它是 static(范围)。

谢谢,它看起来不错。 但我有两个问题。 编辑:它总是需要虚拟 email('xxx@xxx.xxx'”,这意味着我(或其他人)会收到数百封电子邮件。我们能否以某种方式摆脱这一行或将其替换为表单发件人 email (我可以用表单发件人 email(谷歌表单自动添加电子邮件)/那些已经在第 2/3 列中的列替换现有列?

第二件事,如何将虚拟消息行连接到变量:var message = row.join('\n'); (当前添加第 n 行的值)

例如,我们能否以某种方式将 text join 替换为 eg

// Info from specific columns
var Date = lastRowValues[n][5]; //I don’t know how to grab last value from columns, it’s probably something like variable.getLastRow() + variable.getLastColumn() + Get values
var ID = lastRowValues[n][6];
var Code= lastRowValues[n][8];
var Action = lastRowValues[n][9];
var Location = lastRowValues[n][10];
var ErrorType = lastRowValues[n][11];

然后在留言中

// var = message = “You’ve made an error. Please find the details below.” +
“\n “ +
“\n Date of Action:  “ + Date + 
“\n ID:  “ + ID +
“\n Action Code:  “ Code +
“\n Type of Action:  “ + Action +
“\n Location:  “ + Location +
“\n Error Type:  “ + ErrorType  +

rest,如标题,可以保持不变。 我意识到只有数字很难阅读。 有可能实现这个 output 吗? 这就是现在的样子

您可以在链接的电子表格中添加此代码:

// this function will fires automatically 
// it grabs all data from the last row and send it via email

function send_email() {
  var row = SpreadsheetApp.getActive().getDataRange().getValues().pop();
  var message = row.join('\n');
  var subject = 'test subject';
  var address = 'xxx@xxx.xxx';
  GmailApp.sendEmail(address, subject, message);

  // additional emails

  var address2 = row[2];
  GmailApp.sendEmail(address2, subject, message);

  var address3 = row[3];
  GmailApp.sendEmail(address3, subject, message);

}


// this function should be run just once to install the trigger

function install_onFormSubmitTrigger() {
  var ss = SpreadsheetApp.getActive();
  ScriptApp.newTrigger('send_email').forSpreadsheet(ss).onFormSubmit().create();
}

每次提交表单时安装触发器后,表单中的所有数据(= 工作表最后一行的所有单元格)都将发送到xxx@xxx.xxx 以及来自单元格“C”和“D”的另外两个地址。

根据需要随意更改代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM