繁体   English   中英

Google Apps脚本:尝试根据单元格的背景色发送电子邮件

[英]Google Apps Script: Trying To Send Emails Based Upon Background Color Of Cell

我正在尝试创建一个脚本,该脚本检查单元格是否为特定颜色,例如#00ff00。 如果单元格的颜色不是00ff00,我希望脚本使用该单元格中的电子邮件地址并发送电子邮件。 每当我在参数列表之后运行以下脚本“ Missing”(第22行,文件“ Code”)”

有人能帮我吗? 谢谢。

var EMAIL_SENT = new Date() ;

function sendEmails2() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); 
var sheet = spreadsheet.getActiveSheet();

var startRow = 2;  // First row of data to process
var numRows = 2;   // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 3)
// Fetch values for each row in the Range.
var data = dataRange.getValues();

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Trying to get the color of a cell, if the color matches 00ff00, then I       want the for loop to skip that cell and move to the next one.
var cell = sheet.getRange("A1").getBackgroundColor();

If(cell != results.getRange().getBackgroundColor(00ff00)); {


for 
(var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[0];  // First column
var message = row[1];       // Second column
var currentp =  spreadsheet.getUrl();  //current spreadhseet page
var emailSent = row[2];     // Third column
if (emailSent != EMAIL_SENT) {  // Prevents sending duplicates
  var subject = "Sending emails from a Spreadsheet";
  MailApp.sendEmail(emailAddress, subject, message,currentp);
  sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT);
  // Make sure the cell is updated right away in case the script is interrupted
  SpreadsheetApp.flush();
 }}}}

还有一个额外的; 在下面一行{之前:

If(单元格!= results.getRange()。getBackgroundColor(00ff00)); {

暂无
暂无

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

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