A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , , ,

Programmatically setting Folders for Offline Use in Outlook 2003





 
 
Thread Tools Display Modes
  #1  
Old April 30th 06, 02:21 PM posted to microsoft.public.outlook.program_vba
Joseph Awe
external usenet poster
 
Posts: 2
Default Programmatically setting Folders for Offline Use in Outlook 2003

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

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

--
Joseph Awe
Technology Management Group

Ads
  #2  
Old May 16th 06, 04:38 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Programmatically setting Folders for Offline Use in Outlook 2003

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

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Joseph Awe" wrote in message ...
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

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

--
Joseph Awe
Technology Management Group

  #3  
Old May 17th 06, 01:11 PM posted to microsoft.public.outlook.program_vba
Joseph Awe
external usenet poster
 
Posts: 2
Default Programmatically setting Folders for Offline Use in Outlook 20

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 [MVP-Outlook]" wrote:

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

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Joseph Awe" wrote in message ...
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

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

--
Joseph Awe
Technology Management Group


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Offline Folders not Synchronising SimonPerryman Outlook - Installation 1 June 25th 06 08:05 PM
Programmatically changing settings in Outlook 2003 Jonathan Add-ins for Outlook 1 April 7th 06 08:49 PM
Microsoft Office Outlook Offline Folders startup error popping up DAD Outlook - Installation 0 March 14th 06 07:08 PM
Problem with Offline Folders Sue Mosher [MVP-Outlook] Outlook - Installation 2 January 25th 06 10:52 PM
Outlook 2003 Instance Won't Close If Opened Programmatically Michael Bauer Outlook and VBA 3 January 11th 06 04:19 PM


All times are GMT +1. The time now is 02:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Personal Loans - Advertising - Loans - Credit Cards - Cheap Sheets