I have an applescript that I use as an archive filter for my mail. It basically takes all emails 30 days or older and dumps them into a directory organized by year/month.
Like so “On My Mac”
Archive/2007/12
It creates this directory if it doesn’t already exist.
Everything works peachy, but I recently got a .MAC subscription and wish to move my sorted mails onto .MAC. This includes archive emails. My problem is that I can’t figure out the mail path to create a directory within the .MAC folder.
Here’s my current, working script:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with thisMessage in theMessages
set msgDate to (date received of thisMessage)
set msgMonth to month of msgDate as integer
set msgYear to year of msgDate as integer
set mboxName to "Archive/" & msgYear & "/" & msgMonth
try
set mbox to mailbox named mboxName
get name of mbox
on error
make new mailbox with properties {name:mboxName}
set mbox to mailbox named mboxName
end try
move thisMessage to mailbox mboxName
end repeat
end tell
end perform mail action with messages
end using terms from
An appropriate set mboxName is what I need to get directories into the .MAC account. I’ve tried:
make new mailbox with properties {name:mboxName, container:“.Mac”}
set mboxName to “.Mac/Archive”&msgYear & “/” & msgMonth
And so on, but no success. Any help much appreciated.
-james