Jump to content

Entourage: Delete mail with excessive non Alpha subjects

Entourage subjects non Alpha

  • Please log in to reply
No replies to this topic

#1
linuxcoder

linuxcoder

    InsanelyMac Protégé

  • Members
  • Pip
  • 2 posts
I wrote a script to fill a need I couldn't find anywhere else. Deleting emails who have a certain percentage of non Alpha characters in the subject line, so they can skate by keyword filters. So emails like "A+D;U)L`T+ V_I &D#E 0)S" in the subject would be deleted. It's written for Entourage, but the logic could be easily used for other email apps.

on run
	tell application "Microsoft Entourage"
		
		-- delete messages that have <threshhold> percentage of characters
		-- outside the range of A..Z and a..z (and space) in the subject line.
		-- This is to zap emails that substitute special character for letters, to get
		-- past spam filters that drive off key words.  Threshhold can be
		-- adjusted as you see fit.  I arbitrarily chose .15.  Also, the characters
		-- included or excluded in either category can be easily changed.
		-- NOTE:  This permanently deletes, so if you don't want that, just
		-- remove the 2nd delete below.
		
		set CurrMessages to the current messages
		set alphaChar to 0 as integer -- number of Alpha characters and Space
		set otherChar to 0 as integer -- number of non Alpha characters
		set otherRatio to 0.0 as real -- otherChar / alphaChar
		set threshhold to 0.15 as real -- adjust this to whatever works
		
		repeat with theMsg in the CurrMessages
			set subj to the subject of theMsg
			
			repeat with thisCharacter in the characters of subj
				set thisCharacter to thisCharacter as text
				if (thisCharacter ≥ "A" and thisCharacter ≤ "Z") or (thisCharacter ≥ "a" and thisCharacter ≤ "z") or (thisCharacter = " ") then
					set alphaChar to alphaChar + 1
				else
					set otherChar to otherChar + 1
				end if
			end repeat
			
			set otherRatio to otherChar / alphaChar
		end repeat
		
		if otherRatio > threshhold then
			delete theMsg -- put in Deleted Folder
			delete theMsg -- delete permanently
		end if
	end tell
end run






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy