Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

542
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!