Walk folder - using cached folders

J

Jack

I have an application that needs to walk through the folders and determine
the folder type (contact, calendar and task) then execute a task

what I am encountering is a large delay when it walks the Exchange based
folders, regardless if the folders are cached or not.

Is there a way to have it walk through the cached folder and not hit the
server every time it does this? The latency is killing me with the current
code, listed below.

for i = 1 To gobjOutlook.Session.Folders.Count
Set MAPIFolder = gobjOutlook.Session.Folders.item(i).Folders.item(j)
blah
next
 
D

Dmitry Streblechenko

Do not use multiple dot notation. For every dot, COM returns a brand new
object (if that is what the property returns):

set Folders = gobjOutlook.Session.Folders
for i = 1 To Folders.Count
Set MAPIFolder = Folders.item(j)
blah
next

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
J

Jack

So,is it more efficient if I navigate multiple folder levels to do:
set Folders = gobjOutlook.Session.Folders
for i = 1 To Folders.Count
Set MAPIFolders = Folders.item(i).Folders
for j=1 to MAPIFodlers.count
...
next
blah
next

But that creates an object manually???

jack
 
D

Dmitry Streblechenko

That, that is a lot more efficient, but I'd write a recursive function that
takes Folders collection as a parameter.
Not sure what you mean by "But that creates an object manually" and why that
is a problem.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top