View Single Post
  #5  
Old August 13th 08, 11:48 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default VBA or Visual Basic or VSTO for outlook sync?

Does it work if you replace the DoEvents loop with a call to MessageBox()
(which also runs the message loop)?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Alban" wrote in message
...
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