OnError Event

Microsoft Outlook Visual Basic

Occurs when Microsoft Outlook encounters an error while synchronizing a user’s folders using the specified Send\Receive group. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

Sub object_OnError(ByVal Code As Long, ByVal Description As String)

object    An expression that evaluates to a SyncObject object.

Code    A unique value that identifies the error.

Description    Required. A textual description of the error.

Example

This Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays a message box describing the synchronization error when an error occurs during synchronization. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents mySync As Outlook.SyncObject

Sub Initialize_handler()
    Set mySync = myOlApp.Session.SyncObjects.Item(1)
    mySync.Start
    mySync.Stop
End Sub

Private Sub mySync_OnError(ByVal Code As Long, ByVal Description As String)
    MsgBox "Unexpected sync error" & Code & ": " & Description
End Sub