Book Image

Google Apps Script for Beginners

By : Serge Gabet
Book Image

Google Apps Script for Beginners

By: Serge Gabet

Overview of this book

Table of Contents (16 chapters)
Google Apps Script for Beginners
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
7
Using User Interfaces in Spreadsheets and Documents
Index

Retrieving Gmail data


After a couple of years, a normal user's Gmail account is often a compilation of thousands of threads and a lot more messages of all kinds. Some have labels, some remain unread sometimes; I even know people who never delete or archive anything and it can easily become a real mess.

Let us assume you are not one of these people and that you already have a couple of labels to sort your messages in a clever way.

The Gmail app is a service that provides methods to retrieve messages in many ways. We can get all threads without any criteria, threads with a specific label, starred threads, and a few other threads but in this first example, we will focus on our inbox threads (https://developers.google.com/apps-script/reference/gmail/gmail-app#getInboxThreads()).

If you look at the documentation, you'll find two occurrences of the getInboxThreads() method; one has no parameter and the other has two parameters—start and max—to retrieve partial data so that we can process them in...