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

An AppleScript to de-junk messages in Mail.app Apps
Every once in a while, I need to fish some messages out of the Junk mailbox in Mail.app, and it's usually an annoyance sorting them back to their correct folders and marking them so I can find them again. There's nothing that will make the spam checker perfect, of course, but here's a script that makes the recovery process a little easier.
(*
  de-junking script.  save and run from scripts menu at need.
  this script is not designed for accounts with multiple email addresses; 
  it will use the first email address in the list of addresses
*)

tell application "Mail"
  if name of message viewer 1 does not start with "Junk" then return
  -- get selected messages
  set messList to selected messages of front message viewer
  repeat with thisEmail in messList
    tell thisEmail
      -- reset properties
      set junk mail status to false
      set background color to green
      set theList to address of every recipient
      set read status to false
    end tell
    repeat with thisAddress in theList
      -- find originating mailbox and move message there
      set theAccount to (every account whose email addresses ¬
        contains thisAddress and enabled is true)
      if theAccount is not {} then
        move thisEmail to mailbox "INBOX" of (item 1 of theAccount)
        exit repeat
      end if
    end repeat
  end repeat
end tell

-- reset message viewer away from Junk mailbox to something more reasonable
tell application "System Events" to tell process "Mail" to tell window 1 ¬
  to tell splitter group 1 to tell scroll area 1 to tell outline 1
  set theRow to item 1 of (every row whose value of text field 1 is "unread")
  select theRow
end tell
[robg adds: I haven't tested this one. To use, save it to your user's Library » Scripts folder, and run from within Mail.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[4,677 views]  

An AppleScript to de-junk messages in Mail.app | 1 comments | Create New Account
Click here to return to the 'An AppleScript to de-junk messages in Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to de-junk messages in Mail.app
Authored by: lar3ry on Dec 03, '07 09:31:45AM

I use a similar AppleScript to Junk and UnJunk messages. This works nicely with Mail Act-On so that I can just highlight some messages, press the correct keystroke (Ctrl-J to junk, Ctrl-U to unjunk) and batch-junk or batch-unjunk them.



[ Reply to This | # ]