Programmatically setting Folders for Offline Use in Outlook 2003

G

Guest

I'm trying get all the folders and subfolders for a Mailbox and Public
Folders / Favorites to be programmatically set for offline use in Outlook
2003. Below is code that works for traversing the folder trees and setting
the inappfoldersyncobject property.

The problem is that the inappfoldersyncobject property works for subfolders
of the users mailbox folder tree, but not for the subfolders of a Public
Folders / Favorites / Folders. Only the first level folders can be set or
cleared.

There seems to be no information on this subject, and I'm wondering if
anyone has run into this problem. Is this a bug, or registry setting in
Outlook 2003?


Option Explicit

'------------------------------------------------------------------------------------------------------------
Sub SetTreeOffline()

Dim nsMAPI As NameSpace
Dim soAppFldr As SyncObject
Dim fTopFldr As MAPIFolder

Set nsMAPI = Application.GetNamespace("MAPI")
Set soAppFldr = nsMAPI.SyncObjects.appfolders

'- Set the entire Mailbox and subfolders offline
Set fTopFldr = nsMAPI.GetDefaultFolder(olFolderInbox)
Set fTopFldr = fTopFldr.Parent
SetFolderOffline fTopFldr

'- Set the entire Mailbox and subfolders offline
Set fTopFldr = nsMAPI.Folders("Public Folders").Folders("Favorites")
SetFolderOffline fTopFldr

soAppFldr.Start

End Sub

'------------------------------------------------------------------------------------------------------------

Public Sub SetFolderOffline(fldr As MAPIFolder)
Dim i As Integer

'- Set the current folder offline
fldr.InAppFolderSyncObject = True
Debug.Print fldr.Name & " set to offline"

'- If there are subfolders, recursively call the routine
If fldr.Folders.Count > 0 Then
For i = 1 To fldr.Folders.Count
SetFolderOffline fldr.Folders(i)
Next
End If

End Sub

'------------------------------------------------------------------------------------------------------------
 
S

Sue Mosher [MVP-Outlook]

So, what happens when the code tries to iterate the PFFavs collection?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Sue,

The comment over the PFF Tree should have read...

'- Set the entire Public Folder \ Favorites tree offline - DOES NOT WORK!
Set fTopFldr = nsMAPI.Folders("Public Folders").Folders("Favorites")
SetFolderOffline fTopFldr


When you do somthing direct like...

Dim nsMAPI As NameSpace
Dim soAppFldr As SyncObject
Dim fldr As MAPIFolder

Set nsMAPI = Application.GetNamespace("MAPI")
Set soAppFldr = nsMAPI.SyncObjects.appfolders
Set fldr = nsMAPI.Folders("Public Folders").Folders("Favorites").Folders("My
Folder")
fldr.InAppFolderSyncObject = True 'THIS WORKS

Set fldr = nsMAPI.Folders("Public Folders").Folders("Favorites").Folders("My
Folder").Folders("My Sbufolder")
fldr.InAppFolderSyncObject = True 'THIS DOES NOT WORK


I ended up paying MS IT Support to look it the problem. The engineer can
reproduce the problem, but they have not gotten back to me with an answer.

--
Joseph Awe
Technology Management Group



Sue Mosher said:
So, what happens when the code tries to iterate the PFFavs collection?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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