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

Create a Thunderbird-like mail archiving feature in Mail Apps
In my recent Thunderbird 3 usage, I've come to rely on search almost exclusively. I leave messages in my inbox until they are dealt with, and when they are dealt with, I just hit the 'A' key to archive them. Now I can do that with Mail.app, too.

When you hit 'A' in Thunderbird, it archives each message in a folder based on the date of the message, e.g. INBOX/Archives/2010 for messages from this year. The following AppleScript also does this in Mail. (The script will also mark archived messages as read -- Thunderbird's 'A' key does not do that.)

Copy and paste the following into AppleScript Editor:
on run
  tell application "Mail"
    set selectedMessages to selection
    repeat with selectedMessage in selectedMessages
      set msgDate to date sent of selectedMessage
      set msgYear to (year of msgDate) as string
      set mbox to mailbox of selectedMessage
      set acct to account of mbox
      set archivePath to "Archives/" & msgYear
      try
        set archiveMbox to mailbox archivePath
      on error theError
        make new mailbox with properties {name:archivePath}
        set archiveMbox to mailbox archivePath
      end try
      set read status of selectedMessage to true
      move selectedMessage to archiveMbox
    end repeat
    set nextBox to mailbox of last item of selectedMessages
    set nextList to messages of nextBox whose deleted status is false
    set nextMsg to my findNext(selectedMessages, nextList)
    set message viewer 1's selected messages to {nextMsg}
  end tell
end run

on findNext(selectedMessages, allMessages)
  set len to count of allMessages
  set idx to 1
  repeat while idx ≤ len
    set candidate to item idx of allMessages
    if selectedMessages contains {candidate} then exit repeat
    set idx to idx + 1
  end repeat
  if idx > 1 then
    return item (idx - 1) of allMessages
  else
    return last item of allMessages
  end if
end findNext
Save it into your user's Library » Scripts » Applications » Mail folder, and name it Archive selected messages.scpt. I use FastScripts to assign the shortcut Command-Shift-9 to this script (by analogy of the nice MsgFiler).

Problem: this does not always select the right message after archiving. If you have any ideas about that, please share.

[robg adds: This should work in both 10.5 and 10.6; I tested it in 10.5 (where it worked perfectly), and the author refers to AppleScript Editor, which is the new name for Script Editor in 10.6.]
    •    
  • Currently 2.25 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (16 votes cast)
 
[8,098 views]  

Create a Thunderbird-like mail archiving feature in Mail | 6 comments | Create New Account
Click here to return to the 'Create a Thunderbird-like mail archiving feature in Mail' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a Thunderbird-like mail archiving feature in Mail
Authored by: valx on Feb 23, '10 08:09:40AM

Or you can go to the keyboard settings in System Preferences and create a custom keystroke for the menu item Messages > Move to > [Archive Mailbox].



[ Reply to This | # ]
Create a Thunderbird-like mail archiving feature in Mail
Authored by: robg on Feb 23, '10 08:15:09AM

That would simply move the selected messages into a generic Archive Mailbox. The script creates a folder structure based on the year of the email, so you can select a large group of old emails, run the Archive script, and find them sorted into year-based folders within the Archive folder.

-rob.



[ Reply to This | # ]
Create a Thunderbird-like mail archiving feature in Mail
Authored by: Reaperducer on Feb 23, '10 08:44:25AM

I agree with valx -- the workflow you're using seems archaic. The whole point of technologies like Spotlight and the search bar in Mail and MacOS in general is that you don't have to bother with a bunch of folders like back in the days of Pine and Mutt. It's not the 80's anymore.

My method is similar to valx's -- I create a few topic-based mailboxes ("Personal Archive", "Work Archive", "Online Purchases")and when it's time to archive a message, I simply drag the message from my inbox into the archive mailbox.

When it was created and what folder it's in are irrelevant since if I need something old I can just search for keywords in the Mail app or in Spotlight. It also gives the added benefit of spanning across years, which is helpful for things that happen in December and January. I don't know about you, but my mail conversation don't all magically end on December 31 each year.

And since the archive mailboxes are on my IMAP mail server, I can access the messages in them even when I'm away from my computer via my iPhone or a web browser. If all of my messages were archived in dozens of little folders on my computer that doesn't help me when I'm halfway around the world and need to re-print a receipt for that ferry I booked months ago.



[ Reply to This | # ]
Create a Thunderbird-like mail archiving feature in Mail
Authored by: hibbelig on Feb 23, '10 11:12:47AM

My personal workflow is this: Incoming mail goes to my Inbox. It stays in the Inbox until I am done with it. When I am done with a message, I archive it. I don't choose different archive folders for different messages because I find that the global message search provided by both Thunderbird 3 and Apple Mail (via Spotlight) is much better for retrieving old messages.

I like to keep the archive in the same account as the Inbox, however: This way, when processing work messages from home I can find the archived messages from work, too. And vice versa.

The subdivision of the Archives folder by year is done for two reasons: First of all, I feel it might avoid performance issues caused by folders containing lots of messages. Secondly, Thunderbird does it like this and I use different computers, not all of them Macs, so it seemed to make sense to be compatible.

For me, the main appeal of the A key in Thunderbird is: after being done with a message, I don't need to think about where it should go, I just hit A. In the same manner, I hit Command-Shift-9 in Apple Mail. After having tried this for a while, I found out that the cognitive overhead of thinking about which folder a message should go to was larger than I thought, and I felt a huge relief after I realized I don't have to think about that anymore.

Dragging and dropping messages is out of the question for me -- I am a keyboard junkie.

Perhaps that explains the motivation behind it. I realize that different people have different habits. My habit is not catered for by Apple Mail, so I wanted to change it. I thought maybe there are a few readers that also know Thunderbird and that also like the A key and miss it :-)



[ Reply to This | # ]
Create a Thunderbird-like mail archiving feature in Mail
Authored by: valx on Feb 23, '10 09:19:19AM

True. The tip I mentioned would only work well if all of your messages are already organized and you are just processing new incoming mail.



[ Reply to This | # ]
Create a Thunderbird-like mail archiving feature in Mail
Authored by: hibbelig on Aug 15, '11 03:39:58AM

Now, in Lion, Apple Mail has a standard menu command "Archive", but it does not have the per-year substructure that Thunderbird uses.

Does anyone happen to know a way around this?



[ Reply to This | # ]