thescienceguy
thescienceguy

Reputation: 13

Reading Multiple Email Headers with Google Apps Script

I am creating a small application to read email headers.The output is "undefined." Is there a specific coding error, and how can I fix it?

function test() {
  var threads = GmailApp.getInboxThreads(0,5)
  var messages = threads[0].getMessages();
  for (var i = 0; i < messages.length; i++) {
    Logger.log(messages.getRawContent);

  }
}

Thank you.

Upvotes: 1

Views: 174

Answers (1)

Mogsdad
Mogsdad

Reputation: 45710

You forgot to dereference the array returned by .getMessages(), is all:

Logger.log(messages[i].getRawContent);
                   ^^^

Upvotes: 1

Related Questions