Simple script to get all non-Exchange folders in Entourage

HI,
Here is a simple and fast way to get the user’s non-Exchange folders within Entourage. Works relatively fast (I get about .18-.19 sec with no Event log on, ~.27 sec with event log on for a list of 84 folders of varying nesting levels). Works on the user’s folders for the active user.

Use this script to get the listing of the folders as “folder class” meaning that their properties are able to be accessed and the folders can be accessed directly, no need for going through the folder hierarchy again within Entourage. You do need to use Tell Entourage blocks to use the folder items to get further details, such as messages, name, ID, etc.

Enjoy…


-- From John Egan
--  version 1.0
-- feel free to use, attribution is nice but not required. Of course, no warranties of any kind apply
-- adds all non-Exchange folders to a list for later processing
global gFolderListing
set gFolderListing to {}


tell application "Microsoft Entourage" to set TopFolderList to the folders
repeat with nextFolder in TopFolderList
	my GetFolderListing(nextFolder)
end repeat
-- here you can process the folders as you wish by item number inside gFolderListing
-- note that these are not text class entries within the list, instead they are folder class entries 
-- so they have properties that can be referenced wityhin a Tell Entourage block
--  if you use this as a library enter a "return gFolderListing" statement here to get the list for use elsewhere


on GetFolderListing(someFolder) --a recursive handler, finds nested email folders in Entourage
	set end of gFolderListing to someFolder
	tell application "Microsoft Entourage" to set subFolderList to {} & someFolder's folders
	if subFolderList is not {} then -- this folder has subfolders
		repeat with nextSubFolder in subFolderList -- process each subfolder
			my GetFolderListing(nextSubFolder)
		end repeat
	end if
end GetFolderListing