How to convert Exchange Item’s EntryID to EWS unique ItemId via EWS Managed API ConvertId call?

One of my customer requested for some guidance for How to convert Exchange Item’s EntryID to EWS unique ItemId via EWS Managed API’s ConvertId call?

Here is the sample code snippet for converting Exchange Item’s EntryID to EWS unique ItemId via Exchange Web Services Managed API’s ConvertId call:

/*NOTE: Following programming examples is for illustration only, without warranty either expressed or implied,
including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose.
This sample code assumes that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. This sample code is provided for the purpose of illustration only
and is not intended to be used in a production environment.*/

 //Call the GetConvertedEWSID to convert Item’s EntryID to EWSID 
String sEntryID = "AAAAN0ybz+zO+JOhV4pGimkcYQHAAtH+9AAFtlUAAA==";
String sEWSID = GetConvertedEWSID(service,sEntryID, "");
//Pass ExchaneService, ItemEntryID and SMTP address of parent Mailbox of Item as Parameters
private String GetConvertedEWSID(ExchangeService esb,String sID,String strSMTPAdd)
            // Create a request to convert identifiers.
            AlternateId objAltID = new AlternateId();
            objAltID.Format = IdFormat.EntryId;
            objAltID.Mailbox = strSMTPAdd;
            objAltID.UniqueId = sID;

            //Convert  PR_ENTRYID identifier format to an EWS identifier.
            AlternateIdBase objAltIDBase = esb.ConvertId(objAltID , IdFormat.EwsId);
            AlternateId objAltIDResp = (AlternateId)objAltIDBase;
            return objAltIDResp.UniqueId;

Here is EWS SOAP Request and Response for the ConvertId call:


EwsRequest --- <EwsLogEntry EntryKind="EwsRequest" ThreadId="8" Timestamp="9/10/2010 4:26:22 AM">
  <?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="" xmlns:m="" xmlns:t="" xmlns:soap="">
      <t:RequestServerVersion Version="Exchange2010" />
      <m:ConvertId DestinationFormat="EwsId">
          <t:AlternateId Format="EntryId" Id="AAAAN0ybz+zO+JOhV4pGimkcYQHAAtH+9AAFtlUAAA=="   Mailbox="" />

EwsResponseHttpHeaders --- <EwsLogEntry EntryKind="EwsResponseHttpHeaders" ThreadId="8" Timestamp="9/10/2010 4:26:32 AM">200 OK
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
X-EwsPerformanceData: RpcC=0;RpcL=0;LdapC=0;LdapL=0;
Persistent-Auth: true
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Thu, 09 Sep 2010 22:56:32 GMT
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET


EwsResponse --- <EwsLogEntry EntryKind="EwsResponse" ThreadId="8" Timestamp="9/10/2010 4:26:32 AM">
  <?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="">
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="639" MinorBuildNumber="21" Version="Exchange2010" xmlns:h="" xmlns="" xmlns:xsi="" xmlns:xsd="" />
    <s:Body xmlns:xsi="" xmlns:xsd="">
      <m:ConvertIdResponse xmlns:m="" xmlns:t="">
          <m:ConvertIdResponseMessage ResponseClass="Success">
            <m:AlternateId xsi:type="t:AlternateIdType" Format="EwsId" Id="AAMkADM0MDhiYjI5LTY1YjktNGNjOS04ZjdmLWZhZTlmNzdiNjllOQBGAAAAAADdMVg7cuSIleOBbZVAAA=" Mailbox="" />


For reference:

Comments (3)

  1. Doug says:

    The implication of this exercize is that EntryID always converts to the same value and that it is a reversable process. Today I was watching my push notification listener get different ItemIDs for the same Exchange Calendar item (appointment). How is that possible?

    I expected two different itemIDs since there was an appointment for the organizer and one for the required attendee, but the ItemID pushed did not match either of the appointments previous ItemIDs and yet GetItem returned an appropriate appointment.

    How can this be?

  2. Dave Trindall says:

    Hi Doug, I'm by no means an expert, but previous experience developing a MAPI solution for integrating with Exchange led me to read that PR_SOURCE_KEY is actually the permanent ID field used to identify messages, and PR_ENTRYID is actually susceptible to change for what reasons I have no idea. Maybe Brijs can comment?


    –Trindaz on Fedang #EWS

  3. Roman Lonik says:

    EntryId changes when you move appointment, message etc. to another folder.

Skip to main content