none
Find appointments by ID RRS feed

  • Question

  • Hello All,

    We have stored appointment ID's; Appointment.Id in our database.

    Now, what we are trying if Appointment.ID does not exists in users mailbox then we want to delete the appointment details from our database.

    So to do this, we are first searching in users mailbox by Appointment.Id and if not exists then delete details from our database. But we are getting the following error while searching,

    The specified object was not found in the store. 

    try
                {
                    var appt = Appointment.Bind(service, "some appointment Id");
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }

    How to implement this without raising the exception if appointment Id doesn't exists in users mailbox ??

    Regards,

    Rohit

    Tuesday, January 20, 2015 11:25 AM

All replies

  • Yes, Appointment.Bind throws a ServiceResponseException if the item isn't found in the store. You could catch that exception type and continue. If you want to avoid an exception altogether, you could use the ExchangeService.BindToItems method, which allows you to pass multiple ItemIds at once, and returns errors for the Ids that correspond to items not found.
    Wednesday, January 21, 2015 2:15 PM
    Moderator
  • Yes, Appointment.Bind throws a ServiceResponseException if the item isn't found in the store. You could catch that exception type and continue. If you want to avoid an exception altogether, you could use the ExchangeService.BindToItems method, which allows you to pass multiple ItemIds at once, and returns errors for the Ids that correspond to items not found.

    Thanks for the suggestion. I have used ExchangeService.BindToItems method like below;

    IEnumerable<ItemId> item = new List<ItemId> { "id1","id2","id3" };
    PropertySet ps = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Id, AppointmentSchema.LastModifiedTime, AppointmentSchema.DateTimeCreated);
    ServiceResponseCollection<GetItemResponse> result = service.BindToItems(item, ps);

    But, I am not able to find from the result which Id is present OR not; its has returned me Count, ErrorCode, ErrorMessageDetails etc... 

    So how can relate which Id is present OR not and the ErrorCode related which Id ?? Is this is a correct way??

    Even I have tried with for loop on result; But not able to get it what I want !

    Thanks !

    Thursday, January 22, 2015 6:58 AM
  • In your code, result is a collection of GetItemResponse objects. There is one per ID you sent. So you could do:
    foreach (GetItemResponse response in result)
    {
       Console.WriteLine(response.ErrorCode);
    }

    Friday, January 23, 2015 6:01 PM
    Moderator