View Single Post
  #3  
Old August 13th 08, 06:43 PM posted to microsoft.public.outlook.program_vba
Alban
external usenet poster
 
Posts: 7
Default VBA or Visual Basic or VSTO for outlook sync?

Here is my code. I also linked the COM microsoft OUtlook library. I need a
console as I would like to then schedule the task without any user
interaction.

I am still confused with catching event. The more I read on the web, the
less I clarify the way events are treated in VB.NEt, VB, VBA and the role of
VSTO...


Imports Outlook = Microsoft.Office.Interop.Outlook

Module Module1

Public bSendReceiveEnded As Boolean
Public WithEvents mySync As Outlook.SyncObject

Sub mySync _SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub

Sub Main()

' 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
mySync = 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
Ads