Jump to content
InsanelyMac Forum

Entourage: Delete mail with excessive non Alpha subjects

Recommended 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
				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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Posts

    • New Web Driver - 387. for 10.13.4 build 17E202
    • I guess having pre{max-height: 500px;overflow: auto;} in CSS was too much for IPS Devs' tast.  Until an admin has hands on this, you still can use stylish plugin to accomplish it.     In fact, it is pretty easy than it appears - Just apply a simple click on the codebox (it will highlight it), then 'delete' key.
    • all the possible frequencyes i have added seems to work fine at the moment, i have added a lot of different frequencyes to support better all kinds of professional applications, inclunding strange sampling rates and goes from 8khz up to 176.4 khz, unfortunately 192 khz does not seems to work even on cards which should support it like the audigy rx, but other frequencyes just works fine and at the moment i have tested only the sound blaster audigy rx and the audigy sb0090 (1st gen audigy) and i can confirm that all the frequencyes from 8khz up to 176.4 khz does work on that card, so i think that such frequencyes should work on all the audigy 2, 2sz, 4 cards as well, tomorrow i will test with my sound blaster live! cards and i will let you know, but here are also some photos (pro tip: use cmd + alt/opton + 4 and then press space to make a screenshot of a single window):
    • Guy's if something happened, this is most likely Admins and Moderators are working there, yes we still need some things to be done, but if it's still not yet, it's because of time or something we don't know, we just have to be patient! Slow things is just because they are working in the same time, patience for that problem is good, and loading things, but apparently now is good, for me these things I've accounted them yesterday and this morning, but now they are gone. For the missing things like the Old insanelymac and theme, please we need them, and excuse my ignorance!
    • Good evening to all. So, I have an external 1TB seagate HD and it always reads normally, but now when I plug it into my HACK it just does not read, it does not even appear on the disk utility. The light always turns blue from the HD without blinking. However I plugged it into windows, on a macbook and it worked normally. I already formatted my hack but it did not work. Thank you in advance for the help and sorry my bad english   my kexts: AppleALC.kext FakeSMC.kext IntelGraphicsFixup.kext IntelMausiEthernet.kext Lilu.kext WhateverGreen.kext VoodooHDA.kext USBInjectAll.kext NvidiaGraphicsFixup.kext   GTX 1080 Windforce core i5 7º generation 8gb Ram H170M Plus BR