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

234
Visualizações
Google Scripts to Archive Specific Email

I try to create a script that runs once every day to archive all my LinkedIn digest emails from a specific label IF they are older than a set date (i.e. 14) AND the sender's email address is equal to the one I specified. Here is my code:

const autoArchiveLinkedInDigest = () => {
  const daysOlderThan = 14;
  const currentDate = new Date();
  const oldDate = currentDate.setDate(currentDate.getDate() - daysOlderThan);

  const sender = "jobalerts-noreply@linkedin.com";
  const label = GmailApp.getUserLabelByName("myLabel");
  const threads = label.getThreads();

  for (let i=0; i < threads.length; i++ ) {
    if (threads[i].getLastMessageDate() < oldDate && threads[i].getMessages()[0].getFrom() == sender) {
      threads[i].moveToArchive();
      Logger.log(threads[i])
    }
  }
}

However, it doesn't seem to work for me. I gave permission to access my account and set up a scheduler to run the script in the desired interval. I'm not all new to javascript, but newer worked with Google Scripts. What do I miss here? Thanks for your help in advance!

about 4 years ago · Juan Pablo Isaza
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