Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

291
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda