Outlook 2011 filing script problem

I use a script to file and categorize emails in Outlook 2011. It has always worked flawlessly until the latest update, for some reason, and I’m hopeful someone can help me sort it out. The applescript is reprinted below for reference:

tell application "Microsoft Outlook"
set theMessages to selection
repeat with aMessage in theMessages

	set category of aMessage to {category "[category]"}
	set is read of aMessage to true
	move aMessage to folder id [foldernumber]
	
end repeat

end tell

So here’s the problem. If I have a conversation selected or multiple emails, it works fine. If I have a single message, I get the following error message:

osascript: OpenScripting.framework - scripting addition “/Library/ScriptingAdditions/Satimage.osax” cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
/var/folders/f_/15ts5cnx21j188g2dtzkh3d40000gp/T/Keyboard-Maestro-Script-234F50AD-99AE-460F-9D15-864E83B34534:68:236: execution error: Microsoft Outlook got an error: incoming message id 486940 doesn’t understand the “count” message. (-1708)

(Just ran the script on a conversation, and the first part of the error still exists, but it doesn’t seem to affect execution. But I don’t get the execution error, so I think that’s the problem.)

Any thoughts on what is happening here and how to fix it?

Separately, is it possible to tweak to select a whole conversation (i.e., including sent messages)? Even though I see sent messages in the conversation, they’re never filed when I use this script.

Thanks in advance for anyone’s thoughts.

Tony

You should be able to ensure that the selection value is a list, even with just a single selection, by adding as list to the definition of the Messages

set theMessages to selection as list
1 Like

Brilliant! This solved it instantly. Although I have to admit it feels a bit like when you ask someone for directions to a famous landmark and they point to it 100 feet away.

Thanks!

No problem.

( Just a slightly indisciplined bit of interface writing by MS – any value returned from an interface should have a predictable, determinate, and at the very least determinable type.

In this case, if we ask for the class of the value returned by selection for single UI selections, a run-time error occurs – confirming that the problem is Microsoft’s and not yours : -)

Good tip!