Accessing sub-folders from AppleScript

B

BB

How can I access sub-folders from AppleScript?

Stepping through the folders of Entourage with something like

repeat with ix from 1 to count of folders

get name of folder ix
end repeat

will only handle the top-level folders, not the sub-folders.


The folder class does not seem to contain any reference to a folders
sub-folders, so maybe this isn't possible?

I'm using Entourage 2004

Thanks,

Bo
 
B

BB

Oops, I just saw that there is a folder element in the folder class. I can
access folders of folders after all :)

-Bo
 
P

Paul Berkowitz

Yes, that's how you access folders by name, or to get a hierarchy of
folders. AppleScript allows for recursive calls, so you can make a handler
(subroutine) that calls itself, and ultimately get the whole list of
folders. You can include IMAP, Hotmail and Exchange folders too (where the
top level is the IMAP, Hotmail or Exchange account rather than the
application.) I have a recursive handler tucked away that I can show you,
if you wish. Things get a little complicated if you want it for a "Choose
from list".

Note that Entourage resolves all folder references to their IDs. If you know
the ID you can just call

folder id 123

without any of the

folder "C" of folder "B" of folder "A"

terminology.

Note also that you can work backwards - up the hierarchy - by getting the
'parent' of a folder, but you need a workaround when you get to top-level
folders. 'parent' will error there, which is actually the way you know that
they're top-level. If you need to you can confirm it by 'name of parent'
which does not error but gives the correct result "Microsoft Entourage". You
can also check for 'class of parent' (except in that case) to see if the
parent is an IMAP, Hotmail or Exchange account.


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
B

BB

Thanks Paul,

I spent an hour yesterday evening putting together a recursive function in
AppleScript. First time I used recursion in years... Pretty neat :)

I wrote my script because of the new release of DragThing (which can display
the number of unread messages, but only does it for the Inbox), only to find
out that the code I had written was already in the DragThing script, but
commented out... It was a good exercise though ;-)

-Bo
 
Top