Skip to content

Instantly share code, notes, and snippets.

@jeffellis
Last active September 27, 2021 15:49
Show Gist options
  • Save jeffellis/29b1c2b3a59ac590e309d2407944b85b to your computer and use it in GitHub Desktop.
Save jeffellis/29b1c2b3a59ac590e309d2407944b85b to your computer and use it in GitHub Desktop.
Gmail script to move phishing emails to trash
function processInbox() {
// process all recent threads in the Inbox (see comment to this answer)
var threads = GmailApp.search("newer_than:1d");
for (var i = 0; i < threads.length; i++) {
// get all messages in a given thread
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
processMessage(message);
}
}
}
function processMessage(message) {
var body = message.getRawContent();
if (body.indexOf("X-Blackfin-Assessment") > -1) {
message.moveToTrash();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment