A
Alban
Hi,
I am following up on this old thread:
http://www.microsoft.com/communitie...6-ba1a8875c1a7&lang=en&cr=&sloc=en-us&m=1&p=1
I am desperatly unable to catch the sync end event. I am synching an account
with exchange server and need to wait for the end of synch before ending the
program.
Any clue why the following code is not firing the exception?
Thanks in advance for any help
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Public Interface SyncObjectEvents
End Interface
Public bSendReceiveEnded As Boolean
Private WithEvents instance As Outlook.SyncObject
Sub instance_SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub
Sub Main()
On Error Resume Next
' Create an Outlook application.
Dim oApp As Outlook._Application = New Outlook.Application
' Create the name space.
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects
bSendReceiveEnded = False
oSyncs = oNS.SyncObjects
instance = oSyncs.Item(3)
' Send and receive.
instance.Start()
Do While bSendReceiveEnded = False
System.Windows.Forms.Application.DoEvents()
Loop
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
End Module
I added to the project references to the .COM 'Microsoft Outlook 11.0 Object
Library' and to .NET system.windows.forms
I am compiling with VB 2005 express edition and using Outlook 2003
I am following up on this old thread:
http://www.microsoft.com/communitie...6-ba1a8875c1a7&lang=en&cr=&sloc=en-us&m=1&p=1
I am desperatly unable to catch the sync end event. I am synching an account
with exchange server and need to wait for the end of synch before ending the
program.
Any clue why the following code is not firing the exception?
Thanks in advance for any help
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Public Interface SyncObjectEvents
End Interface
Public bSendReceiveEnded As Boolean
Private WithEvents instance As Outlook.SyncObject
Sub instance_SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub
Sub Main()
On Error Resume Next
' Create an Outlook application.
Dim oApp As Outlook._Application = New Outlook.Application
' Create the name space.
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects
bSendReceiveEnded = False
oSyncs = oNS.SyncObjects
instance = oSyncs.Item(3)
' Send and receive.
instance.Start()
Do While bSendReceiveEnded = False
System.Windows.Forms.Application.DoEvents()
Loop
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
End Module
I added to the project references to the .COM 'Microsoft Outlook 11.0 Object
Library' and to .NET system.windows.forms
I am compiling with VB 2005 express edition and using Outlook 2003