How to tell when Exchange is synchronizing?

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

I'm working on Outlook 2003 with Exchange

I have a COM Add-in and one of the functions is to update other items
when a Task Item is a specific folder is changed. The problem I'm
having is that when I change a Task in the folder, Exchange (I think)
goes to syncronize it. When it is doing this the Change event for the
folder is fired. So every single change the change event gets fired
atleast twice (sometimes serveral). Is there way to tell when
exchange is changing the object? This way I can ignore that change
because in some cases its getting fired 5 times for a single change.
Assume I only need user changes and not anything exchange may change
on the item.

Thanks
 
Instantiate a SyncObject variable using WithEvents during Application_Startup to trap the Send/Receive group that is doing the dirty deed.

If you then trap the SyncObject_SyncEnd event, you can determine there that it is safe to continue with your code.
 
Thanks for the replay. I tried to get the SyncObjects as follows

Set oSyncObjs = olApp.GetNamespace("MAPI").SyncObjects

But I get an error "Outlook failed to get the Sync Objects. This is
probably because Outlook is not properly configured for offline mode."

My question is I can't make sure that everyone that will use it will
have it properly configured. Is there a way around this?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
I appreciate your help. I think my description of my problem was
incorrect or not accurate because the syncObject start and end events
are not firing. Perhaps you know what really is going on. When an
item is changed in a folder I respond to it. When outlook checks to
update the folder the change event is fired even though the editable
fields have not changed. In some cases while it is doing this the
change event gets fired multple times for the same object. It only
happens when exchange is updating the folder with the server. Does
this have to do with the SyncObjects? If so I tried trapping it but
the SyncObjects collection only contained one SyncObject called "All
Accounts" and this object never fires the SyncStart or SyncEnd event.
If you can provide me with a little more help I would greatly
appreciate it.

Thanks
 
Is your Exchange account enabled in the "All Accounts" entry of your defined Send/Receive Groups?

I created a group with just Exchange in it, and after initiating a synch through the Send/Receive menu, my code below fired (the Test proc has to run first to initialize the SyncObject). It also ran automatically based on the frequency interval in the group setup, and the SyncStart event fired there as well.

Option Explicit
Dim WithEvents objMySO As Outlook.SyncObject

Sub Test()
Dim objNameSpace As Outlook.NameSpace
Dim objSOs As Outlook.SyncObjects

Set objNameSpace = Application.GetNamespace("MAPI")
Set objSOs = objNameSpace.SyncObjects
Set objMySO = objSOs("Exchange Group")
End Sub

Private Sub objMySO_SyncStart()
Stop
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
In the "All Accounts" group the "include this group in send\recieve" is
checked. Both for online and offline. The schedule automatic
send/recieve is not checked but Outlook does this automatically every
20-30 seconds.

I did a Send/Recieve All and the sync event fired in my code. But it
does not when it sends and recieves on its own (that 20-30 second
interval or so). So i took your exact code and overwrote mine with
yours. Same thing. If I send recieve all the event fires. But it does
not when Outlook syncs on its own. If I set up a auto sync it will fire
on the interval. I'm thinking there is another group that is not
accesible to me in the send/recieve groups that it is using, since it is
sending and recieving but not through the only send/recieve group "All
Accounts".

Do you know of any other way to catch this send recieve? Or if there is
a hidden group somewhere?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
This is expected behavior. You'll only get sync events when you invoke sync programmatically, not when the automatic sync fires.
 
So is there any kind of event or way to track these automatic
syncronizations? Perhaps a undocumented object or something? Or
Perhaps there's just another work around. How would you suggest not
performing an action on an ItemChange event when Outlook is syncronizing
when the sync cannot be trapped with the SyncObject? When outlook is
syncing it fires the ItemChange event serveral times for the same object
and I don't know how not to bypass this besides saving the objects in
the folder as hiddenMessages or a another folder on the system and then
comparing them to see if the data has actually changed. Any
suggestions?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Have ypu found a soulution ,
we are having the same problem

our problem is similar , we are listening to ItemChnage event on the
Mailbox folder,
when a relevant action on a costomaziable form we made is happening
we are addressing the Item ,

Apparaently a syncronization against the Exchange is happening in the
background and we get error
messages , thqat the Item is allready opened - ... please close any
open appoitments.

mymail is : (e-mail address removed)
Save us
Is your Exchange account enabled in the "All Accounts" entry of your defined Send/Receive Groups?

I created a group with just Exchange in it, and after initiating a
synch through the Send/Receive menu, my code below fired (the Test proc
has to run first to initialize the SyncObject). It also ran
automatically based on the frequency interval in the group setup, and
the SyncStart event fired there as well.
Option Explicit
Dim WithEvents objMySO As Outlook.SyncObject

Sub Test()
Dim objNameSpace As Outlook.NameSpace
Dim objSOs As Outlook.SyncObjects

Set objNameSpace = Application.GetNamespace("MAPI")
Set objSOs = objNameSpace.SyncObjects
Set objMySO = objSOs("Exchange Group")
End Sub

Private Sub objMySO_SyncStart()
Stop
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/



Ryan said:
I appreciate your help. I think my description of my problem was
incorrect or not accurate because the syncObject start and end events
are not firing. Perhaps you know what really is going on. When an
item is changed in a folder I respond to it. When outlook checks to
update the folder the change event is fired even though the editable
fields have not changed. In some cases while it is doing this the
change event gets fired multple times for the same object. It only
happens when exchange is updating the folder with the server. Does
this have to do with the SyncObjects? If so I tried trapping it but
the SyncObjects collection only contained one SyncObject called "All
Accounts" and this object never fires the SyncStart or SyncEnd event.
If you can provide me with a little more help I would greatly
appreciate it.

Thanks




"Eric Legault [MVP - Outlook]" <[email protected]>
wrote in message
 
Back
Top