PDA

View Full Version : Help with very simple Outlook 2011 script




simonmason
Jul 21, 2013, 08:34 AM
I have just started playing with Applescript so forgive the simple questions.

I want to set up some scripts that move messages into subfolders and mark them unread - loosely copying the Quick Steps feature of Outlook 2010.

I created a simple script, but had some issues with it so started to reverse engineer a Microsoft sample script - which I fear ended up to be too complicated.

The script I created is below and results in an error "Microsoft Outlook got an error: Can't make current messages into type specifier".

I started off much simpler using some code that others had posted but I got stumped on the very first line:

set selectedMessages to current messages

This line always resulted in an "Expected end of line but got identifier error" - but others are using this statement so I am not sure what is causing this error. If I can get past this I think I can greatly simplify my code below? Thanks.

(*
File Message to specific folder

*)

tell application "Microsoft Outlook"

-- get the currently selected message or messages
set currentMessages to «class CMgs»
-- set selectedMessages to current messages

-- if there are no messages selected, warn the user and then quit
if ((count of currentMessages) < 1) then
display dialog "Please select a message first and then run this script." with icon 1
return
end if

repeat with aMessage in currentMessages
set messageAccount to «class cAct» of aMessage

if ((class of messageAccount is «class Eact») and (messageSender is not missing value)) then

set filingFolderName to "Commercial"
set matchingFolders to (every «class cMFo» of messageAccount whose name is filingFolderName)
set filingFolder to make new «class cMFo» at messageAccount with properties {name:filingFolderName}

repeat with aMessage in currentMessages

if filingFolder is not missing value then
move aMessage to filingFolder
end if

end repeat

end if

end repeat

end tell