Created
February 13, 2025 06:22
-
-
Save bo33b/52a853cbf48f9d663f8b139402e5a5e2 to your computer and use it in GitHub Desktop.
Google Apps Script that archives all labeled messages in the Gmail inbox after 2 days
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 gmailAutoarchive() { | |
// Build the query | |
var query = "in:inbox is:read has:userlabels older_than:2d"; | |
// Get the threads | |
var threads = GmailApp.search(query); | |
// Archive the threads | |
for (var thread of threads) thread.moveToArchive(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment