简体   繁体   中英

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

I'm trying to create a script that checks if a cell is a certain color for instance #00ff00. If the cell color isn't 00ff00, I would like the script to take the email address in that cell and send an email. Everytime I run the following script "Missing ) after argument list. (line 22, file "Code")"

Can someone help me? Thanks.

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();
 }}}}

There is an extra ; before the { on the below line:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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