Rog said:
I think I spoke to soon on this one. if the exchange server time is off or
it is trying to sync objects down from exchange the lastmodificationtime
will be greater that the local sync date time.
back to square one. Anyone have any other ideas?
Basically what you must do is make sure you call the Item.Save method
*only* when you have actually changed something significant in the item.
Calling Item.Save writes the item unconditionally, which resets LastMod;
any time you do this, Exchange will come right along behind you, sync the
item, and save it again.
In other words, when Exchange is the provider, there is already one thing
running that will unconditionally re-write an item once for every time
something else writes that same item [since it was last synced by
Exchange.] If your code does this *too*, it sets-up an endless i/o cycle.
To manage this I check the Item.Saved property before calling the
Item.Save method; I only call Item.Save if Item.Saved = False... but there
are at least a couple of hitches...
One is, if you are working with AppointmentItem or TaskItem, and you
update a recurrence pattern, Item.Saved will not always reflect this,
though you must call Save to keep the changes to recurrence.
Another is that any Item property assignment will cause Saved to return
false, even if the value is unchanged by the assignment. e,g.,
Dim tmp
tmp = Item.SomeProperty
Item.SomeProperty = tmp
' the following condition will evaluate as True
If (Item.Saved = False) Then [..]
So for every Item property I assign, I first check for inequality... but
again there are caveats...
Merely checking for exact programmatic equality will leave you in almost
the same cycle, for instance, Exchange likes a trailing blank line on the
Body property, and it likes to format phone numbers. To me these levels
of change aren't worth the i/o it would take to push them to SQL Server,
so my comparison routines are written to ignore them accordingly.
Also, dates can pose a special problem, depending on where you store them
outside of OL/Exchange, due to low-level differences in the way they are
stored. e.g.,
' assume rs is an ADODB.Recordset connected to SQL Server
rs!LastModificationTime = Item.LastModificationTime
rs.Update
rs.Requery ' simulate retrieving the record at a later time
' the following condition may *not* evaluate as True
' assume the item has not been written since its LastMod was stored
If (rs!LastModificationTime = Item.LastModificationTime) Then [..]
Long story short, though you can't determine which module caused
ItemChange to fire, you can expect -- indeed you must expect -- that
Exchange will routinely do so without significantly changing the item's
content. As such, IMHO, it's more constructive to evaluate what has been
written, rather than what was responsible for writing it.
-Mark