Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AppleScript to move selected Mail messages to a particular mailbox of a particular account. User is asked two times, once for mailbox, once for account to move messages to. [This script](https://gist.github.com/Zettt/6551639) displays only on dialog.
(*
Mail Filer
Files messages in Mail.app using type ahead. Display a dialog for account and one for all mailboxes of that account.
Created by Andreas Zeitler on 2013-09-13
Copyright Mac OS X Screencasts 2013. All rights reserved.
*)
tell application "Mail"
-- choose account
set allAccounts to (name of every account) as list
choose from list allAccounts with title "Choose Account…" with prompt "Please select one account" without multiple selections allowed
set chosenAccount to result as string
-- choose from all mailboxes from chosen account
if chosenAcount is not "" then
set allMailboxes to (name of every mailbox of account chosenAccount) as list
choose from list allMailboxes with title "Choose Account…" with prompt "Please select a mailbox" without multiple selections allowed
set chosenMailbox to result as string
-- move selected messages to chosen mailbox of chosen account
set s to selection
if s is not "" then
repeat with currentMessage in s
move currentMessage to (first mailbox whose name is chosenMailbox) of account chosenAccount
end repeat
end if
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment