Exchange web services: why is ItemId not constant?
Asked Answered
S

3

13

I write a small application, which should automatically process the emails from a public folder. For each email, we want to save some metadata, in a database.

I wanted to use the ItemID to make the link between this metadata and a specific email, and I have just discovered that this ItemId is not constant. For example, if the email is moved from a public folder to another, it will receive another ItemId. That means, that the link between the email and the associated metadata is lost.

So, the problem is, how can I make the link between the metadata and the specific email?

Selfknowledge answered 12/11, 2010 at 11:19 Comment(1)
See also #11827652 which has some code example for saving a guid against an EWS item as a solution for this problem.Oxa
D
7

My understanding is, that the EWS unique id contains the EntryId in some form. Therefore, it will change once the element is moved to another folder.

And while not applicable here, the situation is more complicated with calendar entries, as Exchange destroys and recreates an appointment under certain circumstances, thereby changing the unique id.

This page (http://msdn.microsoft.com/en-us/library/cc815908.aspx) contains an overview over MAPI properties which can be used to identify an object. An alternative to this is that you can add your own id property to the Exchange element (via extended property).

Disquisition answered 14/11, 2010 at 9:27 Comment(1)
The problem I've ran into is when a notification that an item has been deleted comes in, because the extended property is attached to the item, it is not retrievable because it has been deleted along with the item... my related problem here : stackoverflow.com/q/8807765/555384Coastwise
I
1

Item ID Changes. It doesn't remain unique throughout. For accessing an item, one can use GUID.

(The SOAP Request below is for fetching a calendar item.) You can fetch information about an item using GUID in a FindItem call


 <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" 
      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
     Traversal="Shallow">
  <ItemShape>
  <t:BaseShape>AllProperties</t:BaseShape>
  </ItemShape>
  <Restriction>
  <t:IsEqualTo>
  <t:ExtendedFieldURI PropertySetId="6ED8DA90-450B-101B-98DA-00AA003F1305" PropertyId="3" PropertyType="Binary" /> 
  <t:FieldURIOrConstant>
  <t:Constant Value="BAAAAJXIl1MJ8="/>  /* GUID */ 
  </t:FieldURIOrConstant>
  </t:IsEqualTo>
  </Restriction>
  <ParentFolderIds>
  <t:DistinguishedFolderId Id="calendar"/>
  </ParentFolderIds>
  </FindItem>
Ibadan answered 10/12, 2010 at 10:3 Comment(0)
H
0

you have to convert the EntryItemId to EWS unique item id then you can use as primary key to create an entry into the DB

Have a look at:

Link

Huynh answered 12/11, 2010 at 13:39 Comment(1)
No I believe the EntryId changes when items are moved amongst folders too. Sure you can convert between EwsId and EntryId but that doesn't mean it gives you a unique id over time.Oxa

© 2022 - 2024 — McMap. All rights reserved.