411 REFERENCE · Wikibooks
AppleScript Programming/Sample Programs/Archive selected mail
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
This script tell is supposed to tell Mail.app to move the selected mails to a certain directory/mailbox. Is supposed to work with gmail, but is not general. It doesn't work unless everything is configured for this script.
(* This script is commented out because it needs work.
tell application "Mail"
set selectedMails to the selection
if the length of selectedMails is greater than 0 then
repeat with theMessage in selectedMails
if the name of the mailbox of theMessage is "INBOX" then
-- Set "gmail" to whatever your account is called in Mail.app's preferences
if the account of the mailbox of theMessage is account "gmail" then
-- Note: instead of "All Mail" below, I had to use "[Gmail]/All Mail" -Simon, using Mail 3.5 (930.3) & Gmail w/ IMAP
move theMessage to mailbox "All Mail" in account "gmail"
-- Add custom accounts with custom names and custom archive mailboxes here
-- else if the account of the mailbox of theMessage is account "uni" then
-- move theMessage to mailbox "Archive" in account "uni"
else
say "Your mail didn't belong to any account I know."
end if
else
say "Only mails in inbox can be moved"
end if
end repeat
else
say "You have to select mails first"
end if
end tell
*)
Run QuickTime in full screen Mail alert