Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to delete DELETED0.TXT Mail.app messages Apps
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.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[10,980 views]  

A script to delete DELETED0.TXT Mail.app messages | 15 comments | Create New Account
Click here to return to the 'A script to delete DELETED0.TXT Mail.app messages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to delete DELETED0.TXT Mail.app messages
Authored by: balakera on Apr 23, '04 01:09:25PM

Forgive my ignorance,

But how would one set a rule to run before Junk rule? I cannot find a way to do that (10.3.3). In Junk Mail prefs there does not seem to be a way to add a rule to the advanced option. And in Rules, how do I know where to put my rule so it runs before Junk rule?

Thanks



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: olivesoft on Apr 23, '04 03:23:48PM

Rules are executed in order, top to bottom in the rule list. You can change the order of the rules by dragging them in the list with the mouse.

---
-Bob
---------------------
I tend to think of [Mac] OS X as Linux with QA and Taste.
-James Gosling, Java Architect



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: cilly on Apr 23, '04 04:27:31PM

You are right, I also do not have the junk mail rule listed under rules. Probably, since I adjusted to move the junk mail automatically to the junk mail folder.

Anyway, I added the action perform apple script to the junk mail rule in the junk preferences and added an additional rule perform apple script in the rules section.

---
cilly @ http://www.cilly.dyndns.org/



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: jaheem on Apr 24, '04 03:12:46AM

Rules run in the order that they are in in the list. So the first rule on the list will run first. Just click and drag rules up and down to move them around the list.



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: timcrawf on Apr 25, '04 09:38:27AM

Could this script be modified (obviously not by me) to have a list of extensions to look for? Such as .pif, .gif, .jpg, etc.
I saw that Rob modified it for .pif, but from the little I understand about scripting, wouldn't it work best with some sort of variable list?

This is a challenge to the scripters in the room.



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: robJ on Apr 25, '04 03:46:19PM
I don't use Mail but here's a folder action that I have attached to my download folder (on my machine, this is where Eudora's attachments are placed). The folder action can be attached to any number of folders.

 property trashers : {"p7s", "sig"}

 on adding folder items to this_folder after receiving added_items
  repeat with i in added_items
   set info_ to (info for i)
   if name extension of info_ is in trashers or ¬
    name of info_ is "DELETED0.TXT" then
    tell application "Finder" to delete i
   end if
  end repeat
 end adding folder items to
-- Rob

[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: msiple on Apr 25, '04 04:49:35PM

In case anyone cares, DELETED0.TXT are attachment placeholders that Symantec Anti-virus for Email Gateways leaves. It scans inbound email, removes the attachments, which could be a virus or other file as defined by the administrator, and inserts those those files, which contain the details of the file(s) it removed. Unless someone has written a virus to pose as those files, they should be harmless.



[ Reply to This | # ]
Help With Applescript
Authored by: walchang on Apr 27, '04 09:06:16PM
Hi, i know this is kinda off topic, but i got a mac recently and just decided to start learning applescript, and i am having a bit of trouble getting used to it. For example, just trying to make a simple example of opening a safari webpage and setting the url, i typed this up:

tell application "Safari"
	activate
	set page to make new document
	set URL of page to "http://www.yahoo.com"
end tell
and it gives me an error: NSReceiverEvaluationScriptError:4. Even though when i look at other applescripts i can actually understand the code easily, i find that its hard to actually write useful scripts (for me of course, but maybe thats just becuase i suck at it) Coming from a java programmer background, are there any resources i should check to get more familiar with it? I tried the documentation from the ADC, but im still kinda baffled by it; the docs seem kinda outdated.

[ Reply to This | # ]
Caught in loop - Script may fail under certain circumstances
Authored by: hamarkus on Apr 29, '04 02:02:20PM

This is a really useful script, but under certain circumstances you can get caught in a loop. This can happen when you generally leave a copy of your e-mails on your POP-server and only let Mail delete the ones from the server that are moved from your inbox.

The problem is that this does not always works, sometimes Mail does not delete the mails from the server, or deletes them only when they are also removed from the trash or it only deletes mails from server when there new mails to download. I am not really sure, but here is what happened:

I just had an E-mail with such a special attachement, the script moved it into the trash as expected. But it was not deleted from the server. Every time I checked for new mail, it was downloaded again and directly moved the trash, where ever more copies of the mail could be found.

I then emptied the trash, and when I checked for new mail, I saw briefly the line 'Deleting mail' but it also downloaded the mail again. In the end, I had to delete the mail manually from the server. Strangely enough, I had several of such mails and had this behaviour only with one of them.



[ Reply to This | # ]
Try to fix it - failed
Authored by: hamarkus on Apr 30, '04 06:25:00AM
With this script running now running for the second day, my trash was filling up with tons of duplicates of these mails since Mail is not deleting them from the server. Since Mail's settings are 'Remove copy from server after retrieving a message' 'When moved from Inbox', I tried to change the line
 delete eachMessage 
into
 move eachMessage to trash 
but even if invoke the applescript directly, it doesn't do anything, whereas the original script trashes the message. What is wrong with my script? Any help would be highly appreciated.

[ Reply to This | # ]
One step further - but still not there
Authored by: hamarkus on Apr 30, '04 07:50:54AM
o.k. by replacing the line:
 delete eachMessage 
with
 set theAccount to account of mailbox of eachMessage 
 set mailbox of eachMessage to mailbox "Trash" of theAccount 
it now works again, in the sense that it moves the message into the trash, both by invoking the script manually or let the rule do it. But only if I invoke the script manually the message is flagged by Mail as already-downloaded, if I let the rule do the job, the message is downloaded again and again, and each time transfered directly to the trash.

There is probably also a bigger issue with Mail itself, as it seems that none of the Mails I deleted myself manually got deleted on the server.

[ Reply to This | # ]
One step further - but still not there
Authored by: cilly on May 01, '04 04:14:24AM

I am having the same problem. The mail gets downloaded but is not deleted from the POP server, so it gets downloaded and downloaded all the time while my trash is ending up with tons of the same message.

Any help would be apreciated!

---
cilly @ http://www.cilly.dyndns.org/



[ Reply to This | # ]
A script to delete DELETED0.TXT Mail.app messages
Authored by: hamarkus on May 03, '04 04:25:45AM
I had another idea, which did not work either, unfortunately. I wanted to use the Applescript to change the subject line of the mails in question and then use a second rule to delete the mail, since deleting it via a rule works, in the sense that the mail gets added the list of already downloaded mails.
 set the subject of eachMessage to "Junk" 
But for some reason the second rule is not invoked automatically, although I can invoke manually it by selecting the e-mail with the changed subject line in the inbox and choosing 'Apply rules' and it deletes the mail.

And by the way, the problem of Mail not deleting mails from the server seems to be a widespread problem in Panther, as I found out.

[ Reply to This | # ]
Deleting .pif files using your script
Authored by: phnk on Jun 12, '04 04:31:53AM

I recently posted on my weblog a short tutorial explaining how to install an alternative version of this script which targets .pif files.

The tutorial in itself is written in French but all system data (eg.: filepaths, app names) is provided in both French and English. I also took a few screenshots.



[ Reply to This | # ]
Deleting .pif files using your script
Authored by: hamarkus on Jun 24, '04 05:18:06PM

Do you also have the problem that the mails are not added to the list of already-downloaded-mails, meaning that the mails which .pif attachment are downloaded again and again until you manually delete them from the server (although, you won't notice this problem directly since you don't see these mails being downloaded again as they are transfered automatically to the trash)?
Or do you have Mail let the mails delete all e-mails directly when they are downloaded from the server?



[ Reply to This | # ]