none
How To Recognize Calendar Event From ExchangeService.getUserAvailability() Are those From ExchangeService.findItems()

    Question

  • Dear Sir/Madam,

    I am developing integration with Exchange Server by using ews-java-api but found some difficulties on matching results from ExchangeService.getUserAvailability() and ExchangeService.findItems().

    I would like to know how to identify one calendar event of result from ExchangeService.getUserAvailability() is exactly the one from ExchangeService.findItems().

    I can ONLY see "storeid" as one possible identifier in CalendarEvent but haven't seen one corresponding "ID" in Appointment

    Please advice.

    Thanks,

    Tommy




    • Edited by Tommy Chu Friday, May 04, 2018 9:19 AM
    Friday, May 04, 2018 9:10 AM

Answers

  • The StoreID is the HexEntryId of the appointment so you can use the ConvertId operation to convert that to an EWS EntryId and bind to the appointment directly.

    CalendarEvent ce = av.CalendarEvents[0]; AlternateId[] ai = new AlternateId[1]; ai[0] = new AlternateId(); ai[0].UniqueId = ce.Details.StoreId; ai[0].Format = IdFormat.HexEntryId; ai[0].Mailbox = "user@mai"; ServiceResponseCollection<ConvertIdResponse> cvtresp = service.ConvertIds(ai, IdFormat.EwsId); Appointment apt = Appointment.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId);

    You could also request the PR_EntryID as an extended property in your Finditems request or use the
    convertId operation to convert the EWSId from FindItem to the HexEntryId which will match what
    Getuseravailiblity returns.

    • Marked as answer by Tommy Chu Thursday, May 10, 2018 6:00 AM
    Sunday, May 06, 2018 11:55 PM

All replies

  • The StoreID is the HexEntryId of the appointment so you can use the ConvertId operation to convert that to an EWS EntryId and bind to the appointment directly.

    CalendarEvent ce = av.CalendarEvents[0]; AlternateId[] ai = new AlternateId[1]; ai[0] = new AlternateId(); ai[0].UniqueId = ce.Details.StoreId; ai[0].Format = IdFormat.HexEntryId; ai[0].Mailbox = "user@mai"; ServiceResponseCollection<ConvertIdResponse> cvtresp = service.ConvertIds(ai, IdFormat.EwsId); Appointment apt = Appointment.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId);

    You could also request the PR_EntryID as an extended property in your Finditems request or use the
    convertId operation to convert the EWSId from FindItem to the HexEntryId which will match what
    Getuseravailiblity returns.

    • Marked as answer by Tommy Chu Thursday, May 10, 2018 6:00 AM
    Sunday, May 06, 2018 11:55 PM
  • I can convert ID successfully except the calendar event is mark as "Private". There is no "storeid" returned. But, results from ExchangeService.findItem() always contain "Id" no matter what the privacy level is. So, in such case, what should I do ?


    • Edited by Tommy Chu Monday, May 07, 2018 3:23 AM
    Monday, May 07, 2018 3:10 AM
  • That's by design if its private so you have to work with the information that is available datetime/ect
    Monday, May 07, 2018 10:18 PM
  • I am afraid that available datetime would not help as I can create multiple events with same information, datetime etc and mark them all as "private".

    Do you know sorting order of response result is reliable ? What is the theory behind (like First Create First Out) ? 

    Maybe, I can match according to the index from results.

    P.S. The reason why I need to match is I want to get properties from private calendar events without exceptions. Please check (https://social.msdn.microsoft.com/Forums/office/en-US/43614372-c86b-4f29-8962-b202cad18150/calling-getter-of-appointment-throws-exception-if-fetched-without-viewprivateitems-to-target?forum=exchangesvrdevelopment#43614372-c86b-4f29-8962-b202cad18150)
    • Edited by Tommy Chu Tuesday, May 08, 2018 2:50 AM
    Tuesday, May 08, 2018 2:31 AM
  • Privacy is being enforced by the API as I said this is by design you can't override this so you may want to look at using EWS Impersonation which will let you work around it because you then accessing the Mailbox as the owner. Or if you can't and need to keep using delegation make sure that the account is delegated the privacy right using Outlook Delegation.
    Tuesday, May 08, 2018 4:39 AM
  • What I understand from your words is if calendar event is private, without impersonation and privacy right, it is impossible to match, am I right ?

    Also, I am curious that by design GetUserAvailability result doesn't contain "storeid" if event is private but why does FindItem result contains "ewsid" ?  Given that "ewsid" can be converted to "storeid", "storeid" could be also "seen". It is important as it could be used for matching.

    • Edited by Tommy Chu Tuesday, May 08, 2018 10:39 AM
    Tuesday, May 08, 2018 9:29 AM
  • That because they are two different data sets one is querying the FreeBusy information the other is querying the calendar. 

    If your querying the calendar then using GetUserAvailability is completely redundant anyway, I don't see logic to what your doing.

    Tuesday, May 08, 2018 10:06 PM
  • I got an exception when I retrieved properties from private event. (Would you mind to take a look the issue in the link above ? I hope there is something configured wrong by me so I don't need to use GetUserAvailability)

    Therefore, I am trying to use GetUserAvailability to know if event is private. If not, further get information by using FindItems. Do you think there are any other solutions ? 




    • Edited by Tommy Chu Wednesday, May 09, 2018 3:43 AM
    Wednesday, May 09, 2018 3:01 AM
  • >>I got an exception when I retrieved properties from private event. (Would you mind to take a look the issue in the link above ? I hope there is something configured wrong by me so I don't need to use GetUserAvailability)

    Again in this instance your trying circumvent the privacy constraints that the API implements and your getting exceptions which is the correct behavior. In this case the API is doing what it is suppose to do which is not allow you to view the properties which you don't have the correct permission to do so. If you didn't get an exception and got access to the private appointment data that would be issue.

    >>Therefore, I am trying to use GetUserAvailability to know if event is private. If not, further get information by using FindItems. Do you think there are any other solutions ? 

    If you have a valid reason to breach privacy on an appointment then use Impersonation or Delegate options that allows you to view private data

    Wednesday, May 09, 2018 4:01 AM
  • Thanks for your detailed explanation.

    One more question :

    Within the same datetime slot (2018-1-1 10:00 to 2018-1-2 10:00), would index orders of results from above two API be same ? (Maybe, I could match by such pattern) like response[0] == response[0]


    Wednesday, May 09, 2018 9:47 AM
  • No they wouldn't but once your querying the actual calendar the results of GetUseravailblity should be redundant. If your trying to match appointments between two attendees then you should use the PidLidCleanGlobalObjectId  for the reasons outlined in https://blogs.msdn.microsoft.com/mstehle/2009/09/02/ews-uid-not-always-the-same-for-orphaned-instances-of-the-same-meeting/ .
    Thursday, May 10, 2018 5:15 AM