Created
August 10, 2014 16:57
-
-
Save EmmanuelDemey/f2aab0179425a7a1722e to your computer and use it in GitHub Desktop.
Move to trash read email labelledd, or sub-labelled, by a specific string. (in this case Geeks).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function processLabel(label) { | |
| var data = GmailApp.getUserLabelByName(label).getThreads(); | |
| for (var i=0; i < data.length; i++) { | |
| if(!data[i].isUnread() && !data[i].hasStarredMessages()){ | |
| data[i].moveToTrash(); | |
| } | |
| } | |
| }; | |
| function deleteOldMessages(){ | |
| GmailApp.getTrashThreads() | |
| var labels = GmailApp.getUserLabels(); | |
| for (var i = 0; i < labels.length; i++) { | |
| if(labels[i].getName().indexOf("Geeks/")===0){ | |
| processLabel(labels[i].getName()); | |
| Logger.log("label: " + labels[i].getName()); | |
| Utilities.sleep(1000); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment