Semantics of "Run AppleScript" in Entourage

When an AppleScript is run from a rule in Entourage, what is the correct way to determine the context (the messages) over which the script applies. If I say:

on run
Tell application “Microsoft Entourage”
set foo to current messages
– do stuff to each of them
end tell
end run

This does not work. However if I select the messages and run the script it does work. How is the script supposed to know what the new messages are? Do I have to look for all the messages in the mailbox marked as unread?

Does Entourage call a script handler, passing the new messages list? I can’t seem to find much information on scripting Entourage on Microsoft’s site.

Thanks

Tom

I think your syntax is OK. I think that Entourage applies a rule to a single message (if you have a rule to delete messages matching “whatever”, is logical that Entourage applies the rule to a single message, not a bunch of them).

This simple test for incoming messages works for me:

tell application "Microsoft Entourage"
	set list_of_messages to (current messages)
	--> should be a single item list: {message ...}
	set x to subject of (item 1 of list_of_messages)
end tell

say x without waiting until completion

The only flag which Entourage gives us is “current messages” (from dictionary: “message currently being filtered”), and the handler invoked is “run”.