MailArchiveByDate
Sort Mail.app Messages into Archive Folders
MailArchiveByDate is an AppleScript to organize archived email into
separate mailboxes. It can be used with Mail.app under OS X to group
messages based on the date sent so archive mailboxes are broken up into
manageable chunks.
Each time it processes a message, it automatically maintains a folder
hierarchy based on the parent, year, and month:
* parentMailboxName
o 2006
+ 01
+ 02
+ ...
MailArchiveByDate is most suitable when used as a library for another
script which can be run via a MailActOn action to file
selected messages. The reason for having a separate script is so you can
separate personal messages from work messages in the archive.
Using with MailActOn
- Save MailArchiveByDate.scpt and ArchiveMessages.scpt to
~/Library/Scripts/Mail\ Scripts.
- In Mail.app, create a new top-level mail folder called "Archive".
- Set up a MailActOn rule to run your new script:
Description: Act-On: s | Archive Messages
Condition: Every Message
Run AppleScript: ~/Library/Scripts/Mail\ Scripts/ArchiveMessages.scpt
Now when you select one or more messages and press Ctrl-S, they will be
archived to the appropriate sub-folder of your "Archive" mailbox.
For archiving to an IMAP server, edit the ArchiveMessages.scpt script
using Script Editor. Set the IMAP_ACCOUNT property to the name of the
IMAP account as it appears in the list of accounts.
Using with iCal Trigger
In addition to manually archiving messages using MailActOn, it is also
possible to schedule an iCal event to archive "old" messages on a regular
basis.
- Save MailArchiveByDate.scpt, ArchiveOldMessageFromInbox.scpt, and
AutoArchive.scpt to ~/Library/Scripts/Mail\ Scripts.
- Edit AutoArchive.scpt to set the DAYS_TO_SAVE, ARCHIVE_FOLDER and
ACCOUNT_NAMES properties.
- Schedule a recurring event in iCal to run AutoArchive.scpt (set the alarm
to "Run Script" and browse to select AutoArchive.scpt).
To schedule accounts with different DAYS_TO_SAVE, create a copies of
AutoArchive.scpt.
Current Version: 1.5
Released: Sun Apr 15 12:12:13 2007
Download version
1.5
Related Links
- Archiving mail on IMAP server (2007-09-03)
- Version 1.4 of MailArchiveByDate now supports archiving to IMAP folders.
It works exactly as expected for me, but some users have reported problems with the script not creating new mailboxes. If the mailbox exists, the messages are moved. I have not been able to reproduce the problem myself using dovecot on Fedora Core 4 or Scalix (which is supposed to look like an Exchange server).
- Hawk Wings and Mail Archiving (2007-09-03)
- I'm a little behind on my reading, so I just noticed that Tim over at Hawk Wings is linking to MailArchiveByDate. I guess that explains the email I've received in the past few days asking for help. :-)
Tim comments that my update notes for the 1.2 release don't convey much meaning. I looked, and sure enough, they aren't end-user-ready release notes. I'll try again. The original version of the script asked Mail for the current selection. That meant, if you triggered the action, then changed the selection by clicking on the next message, the wrong message might be archived. The new version uses the selection information passed to the script as an argument, so it is more reliable.
That's still not very interesting, unless you are writing your own AppleScripts. Suffice to say, if you are planning to giving it a try, download the most recent version posted.
- Email Archives, redux (2007-09-03)
- Now that I have the site in order, I have posted a copy of my mail archive script in an easier-to-use format.
- Email Archives (2007-09-03)
- Speaking of email, I've been working on an AppleScript to organize my email boxes.
I use Mail.app under OS X, so searching is easy and quick. I can use smart mailboxes as needed for subject-based organization, so I wanted to move away from my existing subject-based organization scheme (a folder for each person, job, client, etc.). But since I have about 7 years of email on my machine, I still wanted to do better than one big mailbox. Grouping the messages based on the date sent seemed to give me manageable chunks, but I didn't want to have to do that manually. So, I came up with this script:
on archiveByDate(parentMailboxName)
tell application "Mail"
set archiveMessages to the selection
repeat with currentMessage in archiveMessages
set receivedon to (date received of currentMessage)
set archiveYear to (year of receivedon as string)
if ((month of receivedon as number)
This automatically maintains a folder hierarchy like:
I use that script as a library, and have another script which I run via a MailActOn action to file selected messages. The reason for having a separate script is so I can separate personal messages from work messages in the archive. For example,
set scriptDirectory to ((path to
scripts folder as string) & "Mail Scripts")
set scriptPath to (scriptDirectory & ":MailArchiveByDate.scpt")
set theScript to (load script alias scriptPath)
tell theScript to archiveByDate("Personal")
saves my personal messages to a folder called "Personal", while
set scriptDirectory to ((path to
scripts folder as string) & "Mail Scripts")
set scriptPath to (scriptDirectory & ":MailArchiveByDate.scpt")
set theScript to (load script alias scriptPath)
tell theScript to archiveByDate("Work")
saves work messages to a separate set of folders.
- Script to archive Mail.app messages by month - The Unofficial Apple Weblog (TUAW) (2007-08-29)
- Go scriptastically fast (2007-04-20)
- You spend a lot of time sorting out your emails (by month as is often the case) but this takes a while (especially if you get the kind of mail volume I do) and you are prone to making mistakes. But if you had something that took care of that for you… like this, that would make life easier.
- Saca más partido a Mail (2007-02-18)
- O un script para archivar los mensajes seleccionados en una estructura de buzones basada en las fechas de los mismos.
- Logiciels en bref (2007-02-06)
- MailArchiveByDate [1.2 - 7.1 Ko - US] est un script pour Mail permettant de classer vos courriels en fonction de leur date de réception. Pour chaque mois, le script crée un dossier et se charge de placer les courriels que vous avez reçu à ce moment-là. MailArchiveByDate peut s’utiliser soit seul, soit avec l’application MailActOn.
- Hawk Wings » Blog Archive » Script to archive mail.app messages by month (2007-02-05)
- At the end of the day, some people just like having things organised neatly into instantly recognisable piles.
For them Doug Hellman has produced an applescript that automates the process of archiving emails by year and month.
- Script to archive Mail.app messages by month (2007-02-05)
- For pro-email users and organization aficionados, Mail.app's archiving abilities leave just a tad to be desired.
