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

232
Vistas
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 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