用 Google 张表格填写 Google 表格

Filling Google Forms with Google Sheets

我有一个 HTML 表单,它保存对 Google Sheet 的回复。该表单包含以下字段:

姓名:
电子邮件:
主题:
留言:

现在,我想要的是 我想在 he/she 将表格填写到“电子邮件”字段中提到的地址后立即自动向收件人发送感谢电子邮件。我不想使用 Google 表单作为后端,因为很难绕过“Response Recorded”确认页面。另外,避免 PHP 对我来说更好!

有没有办法自动发送这些电子邮件?邮件格式如下:

From: <my email address>
To: <email address from the "Email" field in the spreadsheet>
Subject: Re: Submission Received

Hey <name from the "Name" field in the spreadsheet>!

Body of the mail

如果有办法绕过Google表单的确认页面,请告诉我!那也可以!

如果您有 google 工作表中的数据,那么您可以在那里处理自动化。我设置了 this sample file,您可能会以此作为数据集的基础。

从那里我将以下脚本附加到电子表格。 然后您需要设置一个触发器,以某种固定的频率(5 分钟?1 分钟?)执行此脚本。我认为它应该完成你想要的。内置检查以确保不发送部分数据。

const ss = SpreadsheetApp.getActiveSheet();
const sentMessageColumn = ss.getRange("E:E").getColumn();
function regularProcedure(){
  var aCell = ss.getRange(ss.getLastRow(),sentMessageColumn)

  while(aCell.isBlank()){
    var eRow = aCell.getRow();
    
    if(!(ss.getRange(eRow,2).isBlank() ||
      ss.getRange(eRow,3).isBlank() ||
      ss.getRange(eRow,4).isBlank()))
      {
        var newMail = GmailApp.createDraft(
        ss.getRange(eRow,2).getValue(),
        ss.getRange(eRow,3).getValue(),
        ss.getRange(eRow,4).getValue());
        newMail.send();
        aCell.setValue(true);
        }      
      aCell=aCell.offset(-1,0);
  }
}