Skip to content

Instantly share code, notes, and snippets.

@eugenestarchenko
Forked from alimbada/CleanUpGmail.gs
Created October 15, 2025 23:02
Show Gist options
  • Save eugenestarchenko/8a889a975808bf3a630b9c2d51e981ed to your computer and use it in GitHub Desktop.
Save eugenestarchenko/8a889a975808bf3a630b9c2d51e981ed to your computer and use it in GitHub Desktop.
Google Apps Script for cleaning up Gmail
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);
}
@eugenestarchenko
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment