A script to delete DELETED0.TXT Mail.app messages

Apr 23, '04 09:41:00AM

Contributed by: Anonymous

By adding a new Rule in Mac OS X Mail.app (tested in OS X 10.3.3), you can automatically delete, as they come in, all those junk messages with DELETED0.TXT attachments. You must define a new rule to be evaluated before the Junk Rule. This new rule will run the AppleScript which follows at the end of this hint. The messages will be put in the Trash and not in your Junk or INBOX.

(*
Script to delete (move to trash) each message with DELETED0.TXT

Christian Pagé
*)

using terms from application "Mail"
  on perform mail action with messages theMessages for rule theRule
    tell application "Mail"
    	repeat with eachMessage in theMessages
        set theSource to source of eachMessage
        set theAccount to account of mailbox of eachMessage
        try
          if theSource contains "DELETED0.TXT" or ¬
          theSource contains "deleted0.txt" then
            set read status of eachMessage to true
            delete eachMessage
          end if
        end try
    	end repeat
    end tell
  end perform mail action with messages
end using terms from
[robg adds: Although not much detail was provided in the hint on setting up the rule, I think it's relatively straightforward: Create the new rule above your Junk Mail rule, set the "If" pop-up to "Any" and "Every message," and set the "Perform" pop-up to "Run AppleScript," and point it at the script you just creatd. You could easily use an edited version of the script to delete any sort of email based on the name of the attachment. I don't get many of the DELETED0.TXT spams, for instance, but I get tons of .PIF attachment spams.]

Comments (15)


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