Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Google Sheets Scripts - send an email based on a cell being today's date

I've looked all over, but I can't seem to piece the code together from all the different answers out there.

I have 4 columns that are populated by the following: Date Processed, Email, Name, Removal Date

What I'd like to do is send an email to a static email address, including the email address that needs to be removed when cells in the "Removal Date" column equal today's date. I also need this to run once per day.

I've figured out the daily running with the triggers. I've pasted the code below that I'm trying to run. My thought was to put the data into an array, evaluate the 4th column for the dates. Then when the date is today, it returns the entire row so I can use the email listed from the 2nd column.

function SendEmail() 
{
  var presentDay = new Date();
  var rows = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
  var filteredEmails = rows.filter(function(row)
  {
    var removalDate = row[4];
    if (removalDate === Date)
    {
      return row
    }
  })

  Logger.log(filteredEmails);

  var emailAddress = "staticEmail@gmail.com";
  var message = ' needs to be removed'; 
  var subject = 'Member needs to be removed';


        //MailApp.sendEmail(emailAddress, subject, row[2] + message);
    
  
  
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try something like this:

function sendEmails() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Emails';
  const sr = 2; //data start row
  const dt = new Date();
  const tdv = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf();
  const vs = sh.getRange(sr, 1, sh.getLastRow() - sr + 1, sh.getLastColumn()).getValues();
  const fvs = vs.filter(r => {
    let d = new Date(r[4]);
    let dv = new Date(d.getFullYear(),d.getMonth(),d.getDate()).valueOf()
    return dv == tdv;
  });
  fvs.forEach(r => {});//send emails with this loop
}

If you wish to compare dates numerically then you must use valueOf() or getTime();

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!