Saturday, January 22, 2011

Mac Outlook 2011: Keyboard shortcut to quickly file messages

Trying a switch to Outlook 2011 for Mac I needed a keyboard shortcut to quickly move selected email messages to specific folders. I edited some of the default AppleScripts which appear in Outlook's script menu, ended up with a script per folder I want to move messages to. Next step was to assign a keyboard shortcut to each script e.g. Option-A for File Message to Archive, Option-F for File Message to Follow-Up and so on.


A sample script is below, this is the one I use to move messages to a folder named "Archive", I simply created copies of this script for each folder I want to move messages to from the keyboard. The script is saved under ~/Documents/Microsoft User Data/Outlook Script Menu Items/File Message to Archive.scptd

*** UPDATE*** Microsoft released an Office 2011 SP2 upgrade on 4/12/2012, in this version of Outlook the scripts are expected to be placed in the folder: ~/Library/Application\ Support/Microsoft/Office/Outlook\ Script\ Menu\ Items/

The keyboard shortcut mapping is done from the OSX > System Preferences > Keyboard panel, just create a new Application shortcut, pick Outlook 2011 as the application and enter the exact name of your script as it appears in the script menu.


(*

 File message to Archive folder

*)

on run {}
 
 tell application "Microsoft Outlook"
  
  -- listSelectedItems : a list of all items selected in Entourage
  set listMessages to current messages
  
  -- Check to make sure items are selected, if not then quit
  if ((count of listMessages) < 1) then return
  
  -- Iterate through selected items
  repeat with objInSelection in listMessages
   
   set listFolders to mail folders
   
   repeat with objFolder in listFolders
    
    if (name of objFolder is "Archive") then
     set gtdFolder to objFolder
    end if
    
   end repeat
   
   if (class of account of objInSelection is not imap account) then
    -- IMAP currently not supported
    move objInSelection to gtdFolder
   end if
   
  end repeat
  
 end tell
 
end run