Reader small image

You're reading from  Google Apps Script for Beginners

Product typeBook
Published inFeb 2014
Reading LevelIntermediate
Publisher
ISBN-139781783552177
Edition1st Edition
Languages
Right arrow
Author (1)
Serge Gabet
Serge Gabet
author image
Serge Gabet

Serge Gabet has been a professional audio equipment manufacturer for 20 years and is now working for an artistic upper school in Brussels, Belgium as a teacher and Technical Manager. He is also in charge of the Google Apps administration of this school. He develops custom applications using Google Apps Script mainly for his school, though he also works in other areas. He has been designated a Top Contributor by Google since June 2011. He was active on the Google Group Help forum till 2012, then on the Stack Overflow forum (the Google Help Group forum was closed in June 2012), and became a first ranker and an all-time contributor on the Stack Overflow forum a few months back.
Read more about Serge Gabet

Right arrow

Counting, sorting, archiving, and deleting e-mails and threads


We have seen in the earlier examples that it is quite easy to manipulate threads and messages with regard to labels.

Once we get a thread object, we can do what we want with it. A quick look at the documentation shows the many methods available but as I have already mentioned, these operations might take some time and we may easily face issues with the maximum execution time limit of five minutes.

Execution time versus time limit

The solution to this is to proceed with relatively small bunches of threads. A careful approach is to treat 100 threads at a time and continue as long as we need or until it is finished.

Google Apps Script has all the tools we need:

  • A programmable time trigger to automate the process

  • A convenient place to store the number of processed items

  • A way to delete the trigger when it is finished

The following code is an example that will examine all your e-mails and add labels inside every thread according to the thread...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Google Apps Script for Beginners
Published in: Feb 2014Publisher: ISBN-13: 9781783552177

Author (1)

author image
Serge Gabet

Serge Gabet has been a professional audio equipment manufacturer for 20 years and is now working for an artistic upper school in Brussels, Belgium as a teacher and Technical Manager. He is also in charge of the Google Apps administration of this school. He develops custom applications using Google Apps Script mainly for his school, though he also works in other areas. He has been designated a Top Contributor by Google since June 2011. He was active on the Google Group Help forum till 2012, then on the Stack Overflow forum (the Google Help Group forum was closed in June 2012), and became a first ranker and an all-time contributor on the Stack Overflow forum a few months back.
Read more about Serge Gabet