On 11/14/03 7:38 AM, "Jeffrey Berman" <[EMAIL PROTECTED]> wrote:
> Is there a way to structure AppleScript syntax so that an action is carried
> out recursively on messages within all levels of subfolders of an Entourage
> mail account? For instance, how could one write syntax to check the latest
> time received of any message in any of the embedded folders of a particular
> account?
Yes, although recursiveness truly tests Applescript's memory access and
could cause a stack overflow if you get too many levels deep. usually you;d
get nowhere near that with Entourage folders. You have to write a handler -
a subroutine - which can call itself, and keep doing so at each level.
(Usually, once you get it figured out for the next level it works at all
levels.) You would , in teh main script
global cutoffTime
set cutoffTime to date "11/14/2003 7:00 AM"
tell app "Microsoft Entourage"
set topFolders to every folder -- means top-level local folders
repeat with i from 1 to (count topFolders)
set topFolder to folder i of topFolders
set newMsgs to every message of topFolder whose time received <
cutoffTime
-- do something with these, call a handler, whatever
my SubFolderRoutine(topFolder)
end repeat
end tell
on SubFolderRoutine(anyFolder)
tell app "Microsoft Entourage"
set subFolders to every folder of anyFolder
repeat with i from 1 to (count subFolders)
set subFolder to item i of subFolders
set subFolderMsgs to every message of subFolder whose time
received < cutoffTime
-- do something with these, call a handler, whatever
my SubFolderRoutine(subFolder) -- recursion!
end repeat
end tell
return
end SubFolderRoutine
If you need to make a cumulative list of all these messages, or something
like that, then every call to the SubFolderRoutine would be
set newMsgs to newMsgs & my SubFolderRoutine(subFolder)
and the subroutine's last line would be
return subFolderMsgs
rather than just
return
You could just as easily be accumalating a list of message IDs or time
receiveds, or any other property.
If you need to search IMAP folders or Hotmail folders, you need separate
commands to get their toplevel folders before calling the recursion routine
again:
repeat with j from 1 to (count every IMAP account)
set IMAPacct to IMAP account j
set topIMAPFolders to every folder of IMAPacct
repeat with k from 1 to (count topIMAPFolders )
set topIMAPFolder to item k of topIMAPFolders
set newMsgs to newMsgs & every message of topIMAPFolder whose
time received < cutoffTime -- doing cumulative list
set newMsgs to newMsgs & my SubFolderRoutine(topIMAPFolder)
end repeat
end repeat
and so on.
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html
PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html
PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
--
To unsubscribe:
<mailto:[EMAIL PROTECTED]>
archives:
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>