SyncEnd and other Sync Event not firing

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
 
M

Michael Bauer [MVP - Outlook]

If you select the SyncEnd event in the object browser and click f1 you get a
code example. Just ensure that you call the initialize handler from the
Application_Startup event.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 7 Aug 2008 23:23:01 -0700 schrieb Alban:
 
A

Alban

Thanks for the reply. I think my first post was not very clear.
I am trying to create a console application that will do send/receive on an
Outlook account. I need the syncEnd event to control when to terminate the
application.

I think my problem comes from the overall installation of office and
programming it. Here is what I did:
I downloaded Microsoft visual studio express 2005 for visual basic and
created a console application. If I copy/paste the previous code, it does the
sync (provided I put a 2 sec timer to let the sync happen). If I launch
outlook prior to my console application, I can even see the tray icon
performing the send/receive.

My only problem is that I can not catch any event. I tried with item_send or
other events, all failed. So my question could be simpler:

What environment do I need to create a console application which can catch
office events. It is related to installing visual studio tools for office? Am
I confused between VBA and VB? Do I need to add more reference to the VB
project?

I you have clues to put me on track, it would be great!

Thanks in advance

Alban
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top