【发布时间】:2019-05-14 04:11:27
【问题描述】:
我是 JS 的新手,我试图创建一个脚本,每次填写表格时都会触发一封电子邮件。电子邮件需要有一个非常具体的标题和正文,这是在我的工作表中创建的。
具体来说,我需要我的主题行是包含数据的最后一行中的 I 列,而我的电子邮件正文是 F 列。我能够让脚本选择正确的最后一行,但我很难弄清楚了解如何获取正确列的值。
我目前有一段代码我已经尝试过,但我得到了错误
TypeError:在对象 346 中找不到函数 getValue。(第 7 行,文件 “代码”)解雇
function sendEmail() {
// Fetch the email address - This is a specific email address in the sheet I need stuff to go to
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reference").getRange("F2");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var message = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("A1").getDataRegion().getLastRow().getValue() // KMS Survey Text
var subject = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("A1").getDataRegion().getLastRow().getValue(); // KMS Survey Title
MailApp.sendEmail(emailAddress, subject, message);
}
【问题讨论】:
标签: javascript google-apps-script google-sheets