If you are developing an OnSyncEvent sink (see here for an article on how to implement them with managed code), you may need the value of the item being modified before the event took place. Unfortunately, the Eventsink infrastructure only exposes the modified item.
The OnSyncSave event sink is called twice: Before and after the changes have been committed to to the store. In the first call, you can get the original values simply by opening the modified item again.
Let's assume you got the ADO Record instance from the supplied pEventInfo parameter with this code:
1 IExStoreDispEventInfo eventItem;
2 eventItem = (IExStoreDispEventInfo) pEventInfo;
3 Record record;
4 record = (Record) eventItem.EventRecord;
Once you have this record, you can get the permanent url of the item, create a new ADO Record instance and load the original item into that record:
1 try
2 {
3 string url;
4
5 url = (string)record.Fields["http://schemas.microsoft.com/exchange/permanenturl"].Value;
6
7 _TraceSource.TraceEvent(TraceEventType.Verbose, 0, "Opening original item at " + url);
8
9 original = newRecord();
10 original.Open(url, eventItem.EventConnection, ConnectModeEnum.adModeRead,
11 RecordCreateOptionsEnum.adFailIfNotExists, RecordOpenOptionsEnum.adOpenSource, null,
12 null);
13 }
14 catch (COMException ex)
15 {
16 if ((uint) ex.ErrorCode == 0x80040e19)
17 {
18 _TraceSource.TraceEvent(TraceEventType.Verbose, 0, Resources.CannotOpenOriginalItem);
19 return;
20 }
21 else
22 {
23 throw;
24 }
25 }
You can now access the original item and access its properties.