Created
May 15, 2024 22:41
-
-
Save alimbada/5bc5878338ead31b6308ac9fd748baf1 to your computer and use it in GitHub Desktop.
Google Apps Script for cleaning up Gmail
This file contains 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 cleanUpGmail() { | |
var queries = [ | |
'from:([email protected]) in:inbox subject:(from your Steam wishlist on sale) older_than:7d', | |
'from:([email protected]) in:inbox subject:(is live) older_than:1d', | |
'from:ebay.com subject:("is live!" OR "has been relisted") older_than:7d', | |
// Security alerts | |
'from:([email protected]) in:inbox subject:("Security alert" OR "New sign-in from") older_than:1m', | |
// 2FA | |
'from:([email protected]) in:inbox older_than:1d subject:("two-step authentication" )' | |
] | |
var threads = Array(); | |
for(var query of queries){ | |
threads.push(...GmailApp.search(query)); | |
} | |
Logger.log("Cleaning up %s threads", threads.length) | |
GmailApp.markThreadsRead(threads).moveThreadsToTrash(threads); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Settings for the trigger