none
CalendarEventDetails.ID vs ServiceSession.GetItem( ItemId) RRS feed

  • Question

  • I'm trying to get Category information out of Exchange users calendars' CalendarEvents

    From everything I'm seeing this should work:

    byte[] r = ASCIIEncoding.ASCII.GetBytes(calendarEvent.CalendarEventDetails.ID);

    string z = Convert.ToBase64String(r);

    ItemType it = this.OOOaccount.GetItem(z);

    I am getting this exception: "A call to GetItem failed. Error ErrorInvalidIdMalformed: Id is malformed."

    My CalendarEventDetails.ID = 000000000D42E6AE9C91D94092D26762C08567810700D4CECB0510E3554B9E96AD7A69B5DD8E00160D1A1EC80000907604D8DD32F544AA6D8A56116F4F4200822E541A1D0000

    This converts to z = MDAwMDAwMDAwRDQyRTZBRTlDOTFEOTQwOTJEMjY3NjJDMDg1Njc4MTA3MDBENENFQ0IwNTEwRTM1NTRCOUU5NkFEN0E2OUI1REQ4RTAwMTYwRDFBMUVDODAwMDA5MDc2MDREOEREMzJGNTQ0QUE2RDhBNTYxMTZGNEY0MjAwODIyRTU0MUExRDAwMDA=

    Any ideas on what I am doing wrong here?

    Thanks in advance.

    Friday, July 13, 2012 8:02 PM

All replies

  • The ID you get with GetUserAvailability is the HexEntryID of the calendar appointment to Bind to this you need to use ConvertID http://msdn.microsoft.com/en-us/library/bb799665(v=exchg.140).aspx to convert the HexID to the EWSid see http://social.technet.microsoft.com/Forums/en-IE/exchangesvrdevelopment/thread/727d7105-8cdc-4394-808b-7039c2a54958 for a couple of samples.

    Cheers
    Glen

    Monday, July 16, 2012 7:54 AM
  • I'm going to recap what I found based on the info provided.  I got the GetItem(convertedID) to work.  One thing to remember the managed EWS is not installed to the GAC so you have to browse to the DLL.  I was using the EWSProxies for a starting point so I just generated a new connection to the Exchange server in this posted code to get to the ConvertIDs function to convert the calendar event ID to a GetItem ID.  This likely isn't ready for use as a solution but should give someone trying to do this in C# a starting point.  Good luck - documentation on this process is not detailed - Oh and this editor sucks for posting code.

    The working (pseudo)code for the connection:

    Microsoft.Exchange.WebServices.Data.ExchangeService nativeESB
         = new Microsoft.Exchange.WebServices.Data.ExchangeService  (Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2007_SP1);
    nativeESB.Credentials = new NetworkCredential("accountID", "password", "DOMAIN");
    nativeESB.Url = new Uri(@"https://url.com/EWS/Exchange.asmx");

    Now the convert and the GetItem:

    if (calendarEvent.CalendarEventDetails.ID != null)
    {
         Microsoft.Exchange.WebServices.Data.AlternateId[] id = new    Microsoft.Exchange.WebServices.Data.AlternateId[1];
         id[0] = new Microsoft.Exchange.WebServices.Data.AlternateId();
         id[0].UniqueId = calendarEvent.CalendarEventDetails.ID;
         id[0].Format = Microsoft.Exchange.WebServices.Data.IdFormat.HexEntryId;
         id[0].Mailbox = "EmailAddress";
         Microsoft.Exchange.WebServices.Data.ServiceResponseCollection<Microsoft.Exchange.WebServices.Data.ConvertIdResponse> cvtresp
       = nativeESB.ConvertIds(id, Microsoft.Exchange.WebServices.Data.IdFormat.EwsLegacyId);
        string convertedID = ((Microsoft.Exchange.WebServices.Data.AlternateId)cvtresp[0].ConvertedId).UniqueId;

        ItemType it = ...GetItem(convertedID);

        cats = it.Categories;
    }


    JDS


    • Edited by JDSherm Wednesday, July 18, 2012 12:11 PM
    Wednesday, July 18, 2012 12:10 PM