Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Shortcut for moving an email to another folder in Mail.app

Writer Matthew Martinez

How could I setup a keyboard shortcut for Mail.app in OSX Lion so an email in the inbox, which is still unread, when I use this shortcut is moved automatically to some other previously defined folder?

4 Answers

Open up Automator and create a new Service. Set it to receive "no input", then drag Run AppleScript from the left pane to the right.

Paste the following script — note that you have to change my-account to the actual name of the account where your source and destination mailboxes are*. Also, change destination to the name of the destination mailbox under the specified account.

tell application "Mail" repeat with theMessage in {messages in mailbox "INBOX" of account "my-account" where read status is false} set theMailbox to mailbox "destination" of account "my-account" move theMessage to theMailbox end repeat
end tell

If you only want it to affect the general inbox:

tell application "Mail" repeat with theMessage in {messages in inbox where read status is false} set theMailbox to mailbox "destination" of account "my-account" move theMessage to theMailbox end repeat
end tell

Save this service. Then, under System Preferences » Keyboard » Keyboard Shortcuts, create a new keyboard shortcut for this service.

And you're done.


* You can find out the account name by going to Mail's preferences, then under Accounts, see the Description line.

9

You can use the Automator solution for making a Service with the following chunk of AppleScript, which will ask you where you want to move the selected message(s).

use Mail : application "Mail"
use scripting additions
on findMailBox for partialName --display dialog "Looking for mailbox with text " & partialName set allMailBoxes to mailboxes of account "Apple" repeat with m in allMailBoxes if ((offset of partialName in (name of m as string)) ≠ 0) then return m end if end repeat
end findMailBox
display dialog "Destination: " default answer ""
set destinationName to the text returned of the result
set moveTo to findMailBox for destinationName
set theSelection to selection of Mail
repeat with m in theSelection --display dialog "will move message " & (id of m as string) & " to mailbox " & (name of moveTo as string) move m to moveTo
end repeat

I was looking for the same solution, to move messages to a folder and using the dictionary I found this to work in Yosemite.

tell application "Mail" set the_messages to selection repeat with this_message in the_messages set theSender to sender of this_message
move this_message to mailbox "BILL PAY/Mortgage & HOA" of account "iCloud" -- a folder contained by another folder end repeat
end tell 

No longer works works in Mavericks (Mail 7.3)

This does:


tell application "Mail" repeat with theMessage in (every message of (mailbox "current" of account "my-account")) set mailbox of theMessage to mailbox "destination" of account "my-account" end repeat
end tell

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy