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

Use Mail's scriptability to archive messages Apps
This hint will save you a lot of time if you archive your email from last year, quarter, etc. This applies to Apple's Mail.app program only as far as I can tell.

Using Andreas Amann's Mail Scripts, you can archive mail based on date (as well as do a lot of other things). If you select the entire folder structure, there is even an option to preserve the folder hierarchy. Nice. So my 2004 emails are archived in a folder I named "2004," with the entire folder structure preserved within it.

Oh, and unlike most other archiving solutions, it doesn't require FileMaker and it's free. Way to go Andreas!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[10,377 views]  

Use Mail's scriptability to archive messages | 12 comments | Create New Account
Click here to return to the 'Use Mail's scriptability to archive messages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Mail's scriptability to archive messages
Authored by: vdanen on Jan 06, '05 11:23:11AM

An even better way is to setup a mail rule to archive every incoming message... this way you can delete to your heart's content, filter, and so on and still keep an archive of every message you get. It takes a little manual moving each month to keep things clean (typically I have a mbox called Current where everything gets dumped and once a month I just move out last month's messages into it's own mbox). The rule is simple; as your very first rule (or second if you want to do some spam filtering first) do "If [any] condition is met: [Every message] then [Copy message] to [Current]" where Current is the name of my archive mbox. I usually have it as a sub-mbox of a folder called Incoming; in the same folder I have the folders named 2004-12, 2004-11, etc. Then you can just drag them to the desktop to make a separate mbox file and burn them to CD if you like... I archive every single incoming and outgoing message and have for the past 3 years.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: Schwie on Apr 07, '05 12:39:45PM

Can you please explain how you can automatically apply a "Rule" to outgoing messages, or apply a rule to any message I send? It appears that Rules only apply to incoming messages arriving in your inbox, but your post seemed to indicate otherwise...

I like to keep an archive of everything I send and I've been trying to figure this out since I switched from Outlook on a PC.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: richwiss on Jan 06, '05 01:46:50PM

Another nice thing to do is something I have as a holdover from using pine: save each user's message in a pre-defined folder based on their email address. For example, save messages from your boss to "boss" and maybe save all the mail from any other co-worker to "coworkers". I've got a script I wrote to do that, but it's not really packaged well to upload here. If someone has interest in seeing it, I'll clean it up and submit it as an upcoming hint, or just put up a link to a tar file.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: richwiss on Jan 07, '05 09:32:40AM
OK, I made it a slight bit cleaner. Please read the instructions at the top of the script before using it as you have to modify the files before they will work for you. It works well for me, and I hope for you too. And if you modify it to make it better, please share with everyone.

You can grab the script here:

http://salad.cs.swarthmore.edu/~richardw/mail-script/

Good luck.
-Rich

[ Reply to This | # ]

Use Mail's scriptability to archive messages
Authored by: osxpounder on Jan 06, '05 01:52:55PM

Rich, if your script[s] are putting messages into Mail's mailboxes, or into folders in Finder, I'd love to have that! I'd like to do something similar to what you describe.

---
--
osxpounder



[ Reply to This | # ]
Mailbox locking
Authored by: gshenaut on Jan 06, '05 05:08:12PM

The current hint won't need to deal with locking mailboxes, because it scripts Mail.app itself, but external programs that move messages around among mailboxes will have that problem.

It's easy enough to set up mailboxes & move messages around, but the most painful part is to lock the mailboxes while you are doing it. The best solution I've come up with so far is to applescript a brute-force "quit" before fidding around and a "run" afterwords. Is there a better way to do this?

Greg Shenaut



[ Reply to This | # ]
Mailbox locking
Authored by: kenahoo on Jan 06, '05 08:09:51PM

Yeah, instead of using AppleScript you can use Perl or a shell script, where you have flock() and lockfile, respectively. Those use the system's 'flock' call, which is what programs that manipulate mailbox files do behind the scenes.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: richwiss on Jan 07, '05 08:18:13AM

OK, I'll try and get to it today and post it later this afternoon.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: westfoto on Jan 06, '05 04:36:55PM

I get an Applescript error when running this.

This is the error diolog
Can't make «class mbxp» "Sent Messages" of «class mact» "dogbark" of application "Mail" into a Unicode text. (-1700)

So it does not work for me. This would be great way to trim the fat of Mail as it does grow in size with everything that I keep.



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: aamann on Jan 08, '05 01:07:51AM

This has been fixed in the latest version of the scripts (2.5) - please download the newest version from the Mail Scripts home page.



[ Reply to This | # ]
Emails archived, but can't be imported back into Mail...
Authored by: Guntis on Jan 06, '05 05:58:51PM

When I tried to archive just one account's inbox folder, I got error message that TheFile is not defined and script stopped... Somehow selecting mutiple accounts I could archive all previous year's emails successfully. But - what can I do with them now? They are archived as mbx files and there is no way to import them back in Mail!
Can anyone help?



[ Reply to This | # ]
Use Mail's scriptability to archive messages
Authored by: Jwink3101 on Jan 06, '05 10:18:28PM

When i archive i get a nice and clean mbox file that, to my knowledge, looks like an mbox file. The problem is, Mail.app can't import any mboxes made with the scripts.

Also, why not just drag the mailbox from the mailbox section onto the desktop to create an apple (and seemingly only apple) mbox for your mail?



[ Reply to This | # ]