Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda