Class SyncObject (Outlook VBA)
The class SyncObject represents a Send\Receive group for a user. To use a SyncObject class variable it first needs to be instantiated, for example
Dim sot as SyncObject
Set sot = Session.SyncObjects(Index:=1)
For Each
Here is an example of processing the SyncObject items in a collection.
Dim sot As SyncObject
For Each sot In Session.SyncObjects
Next sot
Class
Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for
Dim oocsClass As OlObjectClass
oocsClass = Session.SyncObjects(1).Class
Name
Returns a String value that represents the display name for the object.
Dim strName As String
strName = Session.SyncObjects(1).Name
Session
Returns the NameSpace object for the current session.
The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements do the same function:
Start
Begins synchronizing a user's folders using the specified Send\Receive group.
Public Sub Sync()
Dim nsp As Outlook.NameSpace
Dim sycs As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Dim i As Integer
Dim strPrompt As Integer
Set nsp = Application.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
strPrompt = MsgBox( _
"Do you wish to synchronize " & syc.Name &"?", vbYesNo)
If strPrompt = vbYes Then
syc.Start
End If
Next
End Sub
Stop
Immediately ends synchronizing a user's folders using the specified Send/Receive group.
This method does not undo any synchronization that has already occurred.
Public syc As Outlook.SyncObject
Public Sub Sync()
Dim nsp As Outlook.NameSpace
Dim sycs As Outlook.SyncObjects
Dim i As Integer
Dim strPrompt As Integer
Set nsp = Application.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
strPrompt = MsgBox("Do you wish to synchronize " & syc.Name &"?", vbYesNo)
If strPrompt = vbYes Then
syc.Start
End If
Next
End Sub
Private Sub StopSync()
MsgBox "Synchronization stopped by the user."
syc.Stop
End Sub