An AppleScript to trash empty emails

Feb 27, '06 06:01:00AM

Contributed by: TigerKR

I hate how emails with no subject, no sender, and no content appear in my InBox in Mail. So I wrote an AppleScript to use as a Mail rule to automatically move these void emails to the trash. Open up Script Editor, and paste in this code.

Save the file to your user's Library -> Scripts -> Applications -> Mail folder, and call it Void Email Trasher.scpt. Then open up Mail, go to Preferences, and click the Rules icon. Create a new rule (give it a description such as "Void Email Trasher"), and set these conditions:

If "any" of the following conditions are met:

Then hit OK to save your rule. Now any new blank messages will be automatically trashed.

[robg adds: You could also use a straight Mail rule to do most of this. Check for 'all' conditions met, and set 'Subject,' 'is equal to,' and then a blank box. Add a similar condition for 'From' and 'Content.' The only thing you won't be able to do this way is check for the blank line (and do the 'or' logic for the blank or empty line).

My apologies for the above -- I tested it, right up to the 'save the rule' step.

I haven't tested the AppleScript, as I have yet to receive an email that would be caught by it.]

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060219013239415