none
EWS Managed API 1.1: How to check whether the property is loaded in Exchange object (Task, Appointment,...) RRS feed

  • Question

  • Hello,

    I'm using EWS Managed API 1.1 and Exchange Server 2007 SP2. 

    I receive in one part of my code exchange object (derrived from Microsoft.Exchange.Webservices.Data.Item - basically it can be Appointment, Task, Contact or EmailMessage) that can have loaded any property but I don't know which properties are loaded at this point. All I can do is to try to get values of all properties in try-catch block, and if "not loaded property" exception occures I try to load next property.

    But this is quite ugly and time consuming solution.

    Monday, February 27, 2012 9:25 AM

Answers

  • You can use TryGetProperty to check if a property is currently loaded eg

                    Object PropVal;
                    if (itItem.TryGetProperty(ItemSchema.Categories, out PropVal)) { 
                        
                    }

     Or you can get all the loaded props using

    var PropCollection = itItem.GetLoadedPropertyDefinitions();
    Cheers
    Glen
    • Marked as answer by Roman Lonik Wednesday, February 29, 2012 6:25 AM
    Wednesday, February 29, 2012 4:29 AM

All replies

  • You can use TryGetProperty to check if a property is currently loaded eg

                    Object PropVal;
                    if (itItem.TryGetProperty(ItemSchema.Categories, out PropVal)) { 
                        
                    }

     Or you can get all the loaded props using

    var PropCollection = itItem.GetLoadedPropertyDefinitions();
    Cheers
    Glen
    • Marked as answer by Roman Lonik Wednesday, February 29, 2012 6:25 AM
    Wednesday, February 29, 2012 4:29 AM
  • Great, this is exactly what I was looking for. Thank you very much Glen.
    Wednesday, February 29, 2012 6:26 AM