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
 
Joined
May 2, 2008
Messages
3
Reaction score
0
Sending to A Group / multiple users

Hi​
2 related questions​
1. How do I code to send to a Group e-mail e.g. WorkGrp​
Would I just type​
With olMail​
.To = "WorkGrp"​
and​
2. If I want to send to 3 separate users who were not part of a Group e-mail​
Would I just type​
With olMail​
.To = "user1", "user2", "user3" etc.​
 
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
 
Joined
Jan 18, 2016
Messages
1
Reaction score
0
Hi All,

I am new to VB and am trying something on the similar lines.

What I attempt to do -
---------------------------

Whenever I open outlook, it should read all the unavailable inbox emails and fetch subject names of each of them. As already mentioned in multiple forums, the code to fetch the subject when placed inside Application Startup event runs ahead of the inbox sync up/refresh owing to which the new items still stay as new and are not processed by the application startup event.

What I tried:
---------------

1) Tried using the Syncobjects method in VB code. Here also the SyncStart event fires and the SyncEnd event fires(The later was initially not firing) in outlook 2010. But still it was the same, the new emails were loaded only after the Startup event.(The Send/Receive was enabled)
2) Tried reconfiguring outlook 2010 to exclude the option to automatically send/receive after internet connection is established. Then also I see send/receive happening automatically after I open outlook even without any macro. When I place the macro, then also it fires the events Syncstart and Syncend(Not sure if they get fired, but just gave a msgbox inside them and it came over there). Two questions here, Does Outlook 2010 do send/receive even if we disable the option. 2) If the Send/Receive is enabled and if the syncobjects code is used with Syncstart and Syncend events, which one takes preference. The Auto send/receive or the Syncobjects ?
3) Not sure if SyncEnd works too in some cases. Is there anyway wherewe can monitor the status of Mysync.start where Mysync is declared as Outlook.Syncobjects. This way I can trigger the remaining code after the status of this command is successful or success or complete.
4) Also tried VBA codes to go to toolbar and do send/receive. Again here the question 2 pops up. (If there is an inbuilt send/receive after connection is established, would the code be needed ?)
5) Is there way to pause a command for sometime in VB before executing the next(Again if I do this, i just estimate and do. If I hold for just 30 seconds before processing the code(Assuming it only takes 30 seconds to sync up after application startup). This again varies depending upon the volume of emails.

Have been trying the same, but ended up with nothing concrete. I feel Option 3 is somthing that I would wish. Please let me know if there is a way to monitor the Syncstart operation for its completeness before executing the code for mail processing.
It would be of help if someone posts the complete code. Have already tried bits and pieces of the ones listed above and it didnt seem to help :( :( :(

Thanks in Advance !!!!
 

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

Similar Threads


Top