This morning was my first foray into the world of Applescript, and it was surprisingly painless. My basic need was to have a key shortcut for each of three tasks that I do continuously in Mail in a semi-GTD fashion:
- Mark a message as Unread and move it to my @Action folder
- Mark a message as Unread and move it to my @Hold folder
- Move a message to my @Archive folder
After a little research I found various scripts that did small parts of these tasks from which I gleaned my first working scripts for Mail.app.
Here’s the @Action script
tell application "Mail"
set s to selection
repeat with eachMessage in s
set read status of eachMessage to false
move eachMessage to mailbox "@Action"
end repeat
end tell
Fairly simple really, eh?
Shortcut keys
My next task was to get Mail.app to recognise the scripts and find a way to assign key shortcuts to them. I tried getting the scripts to appear for about 5 minutes before I figured that the best way to get key shortcuts working would be to use Quicksilver triggers.
Thankfully Quicksilver also has scopes for it’s triggers. This worked perfectly for my scripts. I simply created the trigger, set the key combo and specified the scope to only activate this trigger in Mail. No overloading of key combos, no moving mail messages around when I’m using other programs, no fuss.
The keys I used were cmd-shift-A to Action, cmd-shift-R to Archive and cmd-shift-H to Hold. I tried them out before assigning them and got the reassuring “bing” confirming they weren’t already active combos.
The upshot
Using this method I can now instantly move my selected message(s) into whichever folder I need to and keep my inbox clear. The half an hour or so of research and coding will save me untold hours over a long period of time and it also pleases the geek in me that I’ve consigned yet another task to the keyboard, pushing my mouse and trackpad further into obscurity.
Moran | 31-Aug-06 at 7:17 pm | Permalink
Hi,
I’m trying to get this to work in my setup and I’m having trouble with the move command. the scripts run and give me a “can’t get mailbox “Archive”" error.
Are your mailboxes nested inside the inbox?
Splee | 01-Sep-06 at 12:14 pm | Permalink
No, my mailboxes aren’t nested. Do the mailboxes you’re trying to move mail to already exist? Are you certain you’ve not made a typo in the name of the mailbox?
Being fairly new to AppleScript myself, I can’t really troubleshoot these things remotely I’m afraid.
Keep me up to date on your progress though, if there’s any help I can offer I’ll gladly give it.
Tait Stevens | 10-May-07 at 3:24 pm | Permalink
Steps that worked for me:
1 Create a folder “QS Scripts” in /Library/Scripts/Mail Scripts
2 Copy Applescript from example.
3 Change “@Action” to reflect target folder.
4 Save with .scpt extension in “QS Scripts” folder, above
5 In QS Catalog section, verify that Scripts (All Users) is checked. Hit rescan.
6 In QS Triggers section, create movetofiled script (Run). In drawer, set hotkey to trigger action and specify scope.
Tim Su | 21-Jul-07 at 7:11 am | Permalink
note that if you have multiple accounts, you have to specify:
move msg to mailbox “mailboxname” of account “accountname”
I set up a similar script, except at the beginning of the script, you are prompted to enter the first letter of the mailbox you want to move the message to. just like my old mail client sylpheed =)