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

539
Vistas
Google Scripts - getFrom() is not a function error

I had this working before, without an issue, however ever since I put a filter in to remove all threads with more than 1 email it is now coming up with the not a function error. I remove the filter and it still comes up with the error, unsure what has caused this to completely break on me

    function extractEmails() {
  var htmlBody = getEmailHtml();
  var labelName = "auto-reply-incoming";
  // get all email threads that match label
  var receivedSearchQuery = "label:"+labelName+" -is:sent";
  var threads = GmailApp.search(receivedSearchQuery, 0, 500);
    threads.forEach ((t, i) => {
      let messages = t.getMessages();
      let name = messages.getFrom();
      let messageCount = t.getMessageCount();
      if (messageCount > 1) {
        label.removeFromThread(t);
      }
      if (messageCount <= 1) {
        message.reply("Hi " +name+" \n" + "insert text here");
      }
    });
};
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

accidentally removed part of the script, fixed with the following code:

messages.forEach ((m, j) => {
      let name = m.getFrom();
      m.reply("Hi " +name+" \n" + "insert text here");
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

Replace

let name = messages.getFrom();

by

let name = messages[0].getFrom();

The above because getFrom() is method from Class GmailMessage but messages is an Array.

Reference

  • https://developers.google.com/apps-script/reference/gmail/gmail-message#getfrom
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