tell application "Microsoft Entourage" --
set currentMessages to current messages --
repeat with i from 1 to (count currentMessages) --
set theMsg to item i of currentMessages
my ProcessMsg(theMsg) --
end repeat --
end tell --
on ProcessMsg(theMsg) --
tell application "Microsoft Entourage"
try
set aFolder to storage of theMsg
activate
try
set mailWindow to first browser window whose displayed area is mail area
select mailWindow
on error -- there's no browser window set to mail at the moment
open main window -- opens, or brings current front browser to front
set displayed area of main window to mail area
set mailWindow to main window
end try
set the displayed feature of mailWindow to aFolder
set the selection to { theMsg}
on error theErr
display dialog theErr
end try
end tell
end ProcessMsg
