所以,我有一个谷歌表格,并根据提交的表格的数据,生成一个响应,我希望通过电子邮件发送给完成表格的人的回复 有没有办法在答案纸中插入新行时发送电子邮件?
答案 0 :(得分:4)
我过去完成此操作的方法是编写一个简单的Google文档脚本来收听电子表格的onChange触发器,并发送包含所述表格行内容的电子邮件。以下是具体步骤:
function sendEmailOfLastEditedRow() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lastRow = sheet.getLastRow();
var numRows = 1; // Number of rows to process
var cols = sheet.getLastColumn();
// Fetch the range of cells A2:D5
var dataRange = sheet.getRange(lastRow, 1, numRows, cols)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
// Fetch your row as an array
var lastRowData = data[0];
// Format data by separating values into comma separated list for email
var emailContent = lastRowData.join(",");
// Send an email (change this to your email)
MailApp.sendEmail('alex@simoes.com', 'Email subject', emailContent);
// Log contents for debugging
Logger.log(emailContent);
}