Created
June 8, 2017 15:43
-
-
Save maikzumstrull/d6e5ca662c6a6d1b0919433a099595e5 to your computer and use it in GitHub Desktop.
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 findPhishMeSpam() { | |
var header_re = /^X-PhishMeTracking:/m; | |
var l = GmailApp.getUserLabelByName("PhishMe") | |
var threads = GmailApp.getInboxThreads(0, 20) | |
for (var i = 0; i < threads.length; i++) { | |
var t = threads[i] | |
var messages = t.getMessages() | |
for (var j = 0; j < messages.length; j++) { | |
var m = messages[j] | |
var raw = m.getRawContent() | |
var headers = raw.substring(0, raw.indexOf("\r\n\r\n")) | |
if (headers.search(header_re) >= 0) { | |
t.markUnimportant() | |
t.markRead() | |
t.addLabel(l) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment