我想为Google电子表格创建一个脚本,当另一个特定单元格被编辑时,该电子邮件会向特定行和列中的地址发送电子邮件。例如。编辑单元格E5,以便将电子邮件发送到B5中的地址;编辑单元格E6,以便将电子邮件发送到B6等地址
现在我有以下代码(已编辑的URL),但只要编辑任何单元格,它就会发送到B列中的电子邮件地址,而不是特定的单元格:
function Sheet1() {
var s = SpreadsheetApp.openByUrl("https://xxxxxxxxxxxxx");
var sheet = s.getSheetByName("Sheet1");
var startRow = 1; // First row of data to process
var numRows = 1000; // Number of rows to process
var data = sheet.getSheetValues(startRow,1,numRows,1000) // (startrow, startcolumn, #rows, #columns)
// var data = dataRange.getValues();
Logger.log(data);
for (var i=0;i<numRows; i++) {
var email = data[i][1]; //1st column is preferred email (note count begins from 0)
var accountsNotes = data[i][5];// 5th column is team notes
var subject4TCemail = "[Alert] Your escalation has been updated";
var body4TCemail = "Be Calm and Carry on... Also please check the escalation form here";
//var changedcellvalue=e.value;
// var returnedrange=e.range;
// Logger.log(changedcellvalue);
if (email!="") {
GmailApp.sendEmail(email, subject4email,body4email);
};
}}
您如何建议将其编辑为仅在特定列中的单元格发送到该特定行中的地址时?谢谢!