MORE INFORMATION
The functionality that is available to you to programmatically set up offline settings and to configure offline settings widely varies. This is based on the
version of Microsoft Outlook that you use. This article describes what functionality is available in each version of Outlook. For additional information about implementing solutions, see the
corresponding documentation for the offline setting that you want to use.
Overview of offline support that is available through the Outlook user interface
Before the features that are available in the Outlook
object library are described, it is helpful to understand how synchronization features have
evolved in Outlook.
Outlook 97 and Outlook 98 let you synchronize one group of folders so that you can use that group of folders offline. After you configure that group of folders for offline use, you can indicate that group of folders that you want to
synchronize by using the Offline Folder files (.ost).
Outlook 2000
introduced "synchronization groups." The "synchronization groups" feature lets you set up different groups. Each group represents a specific set of
folders that you want to synchronize. For example, you can set up a group that is named "Full
Sync" so that all folders are synchronized. Alternatively, you can set up a group
that is named "Quick Sync" so that only your Inbox and your Calendar are
synchronized.
Outlook 2002 integrated the "Send/Receive" operation with the functionality of the synchronization groups. The "Send/Receive" groups let you specify the accounts that perform the "Send/Receive" operation. You can also specify the
folders that are synchronized.
Overview of programmatic support for synchronization features
The Outlook 97 object model and the Outlook 98 object model do not
provide any support for offline synchronization features. However, you can use the
Collaboration Data Objects (CDO) 1.2
x object library to set the
PR_OFFLINE_FLAG Boolean property for a folder.
The
PR_OFFLINE_FLAG Boolean property indicates whether that folder is synchronized for offline
use. You can use Extended MAPI in Microsoft Visual C++ .NET to indicate if a folder is synchronized for offline use.
In Outlook 2000, you can set the
PR_OFFLINE_FLAG property, and it
works. The
PR_OFFLINE_FLAG property specifies whether that folder is part of the default "All
Folders" synchronization group.
In Outlook 2002, you can set the
PR_OFFLINE_FLAG property, and it does not work. The
PR_OFFLINE_FLAG property does not work because of
architectural changes that are related to the new "Send/Receive" groups.
The following
Microsoft Visual Basic for Applications code sample shows how you
can use the CDO 1.2
x object library in Outlook 97, in Outlook 98, or in Outlook 2000
to specify whether a folder is synchronized for offline use. Make sure that you
reference the "Microsoft CDO 1.2
x Object Library."
Visual Basic for Applications code sampleSub SyncAllFolders()
Dim objSession As MAPI.Session
Dim objInfostore As MAPI.InfoStore
Dim objInbox As MAPI.Folder
Set objSession = CreateObject("MAPI.Session")
' Log on to the current Outlook session.
objSession.Logon "", "", False, False, 0
Set objInbox = objSession.Inbox
Set objInfostore = objSession.GetInfoStore(objInbox.StoreID)
' Change the root folder of the default store.
ChgFolders objInfostore.RootFolder
objSession.Logoff
Set objInfostore = Nothing
Set objInbox = Nothing
Set objSession = Nothing
End Sub
Sub ChgFolders(objFolder As Folder)
Const CdoPR_OFFLINE_FLAG = &H663D0003
Dim objFoldersColl As MAPI.Folders
Dim objOneSubfolder As MAPI.Folder
Dim objFields As MAPI.Fields
Dim objOfflineFlag As MAPI.Field
If Not objFolder Is Nothing Then
Set objFields = objFolder.Fields
Set objOfflineFlag = objFields.Item(CdoPR_OFFLINE_FLAG)
If objOfflineFlag Is Nothing Then
Set objOfflineFlag = objFields.Add(CdoPR_OFFLINE_FLAG, 1)
End If
objOfflineFlag.Value = 1
' This is an error trap because the default folders cannot be changed.
On Error Resume Next
objFolder.Update
' Loop through all the subfolders and change them.
' Get the folders collection of the folder.
Set objFoldersColl = objFolder.Folders
' Verify whether the folders collection is not empty.
If Not objFoldersColl Is Nothing Then
' Get the first folder.
Set objOneSubfolder = objFoldersColl.GetFirst
' Loop through the folders collection.
While Not objOneSubfolder Is Nothing
' Get the next folder.
Debug.Print objOneSubfolder.Name
ChgFolders objOneSubfolder
Set objOneSubfolder = objFoldersColl.GetNext
Wend
End If
End If
Set objFoldersColl = Nothing
Set objOneSubfolder = Nothing
Set objFields = Nothing
Set objOfflineFlag = Nothing
End Sub
Some synchronization features are added to the Outlook 2000
object model. These synchronization features are based on a "SyncObjects" collection. The "SyncObjects" collection represents the
various synchronization groups that you can configure for a user. You can
programmatically start and then programmatically stop a particular synchronization group. Your
solution can monitor the following new events:
- SyncStart
- SyncEnd
- Progress
These events only respond to synchronizations that are
programmatically started. You cannot interact with any actions that the user may do. There is no direct support for modifying the synchronization
groups. However, the CDO code can modify the "All
Folders" synchronization group.
The Outlook 2002 object model provides enhanced features when you compare them to the Outlook 2000 object model features. The enhanced features in Outlook 2002 occur because the
InAppSyncFolderObject
object is added to each
MAPIFolder object. If you set the
InAppFolderSyncObject property to true, Outlook adds this folder to a "Send/Receive" group that is named "Application Folders." If
the "Application Folders" group does not exist, this group is automatically created the first time that a
folder is added to this group. The "Application Folders" group is the only group
that is designed for developer use. You cannot programmatically modify any other
"Send/Receive" groups that users may have available to them.
There
are no direct synchronization process changes that are made to the Outlook 2003 object library. However, there is now support for the
ConflictItems object. The
ConflictItems object can be
associated with the synchronization process.