J
Joseph Awe
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
'------------------------------------------------------------------------------------------------------------
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
'------------------------------------------------------------------------------------------------------------