none
Extended Properties Question RRS feed

  • Question

  • I'll preface this question with I have spent a week reading the API 1.1 docs, going through the examples, and browsing the forums.  I'm still confused in regards to getting extended properties specifically on a contact.  I am able to get the firstclass properties and I have been trying to implement this doc: http://207.46.16.248/en-us/library/gg274394(EXCHG.80).aspx

    Problem:

    I want to get the extended properties that are not firstclass. For example the Hobbies, SelectedMailAddress, etc.

    What I have coded:

    I understand that I need to do something like this:

    Guid propertySetID = new Guid("{00062004-0000-0000-C000-000000000046}");

                ExtendedPropertyDefinition Hobby = new ExtendedPropertyDefinition(

                    propertySetID,

                    14915,

                    MapiPropertyType.String);

               ExtendedPropertyDefinition SelectedMailingAddress = new ExtendedPropertyDefinition(

                    propertySetID,

                    32802,

                    MapiPropertyType.Integer);

     

       ExtendedPropertyDefinition[] Fields = new ExtendedPropertyDefinition[] { Hobby, SelectedMailingAddress };

                PropertySet extendedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties,Fields);

    ..............

    I have a function where I pass in the ExchangeService such as

    private static void ListContacts(ExchangeService svc)

    {

        //I can even get the total # of contacts to set the View using:

            Folder ContactsCount = Folder.Bind(svc, WellKnownFolderName.Contacts);

     

                ItemView thisview = new ItemView(ContactsCount.TotalCount);

     

    Guid propertySetID = new Guid("{00062004-0000-0000-C000-000000000046}");

                ExtendedPropertyDefinition Hobby = new ExtendedPropertyDefinition(

                    propertySetID,

                    14915,

                    MapiPropertyType.String);

               ExtendedPropertyDefinition SelectedMailingAddress = new ExtendedPropertyDefinition(

                    propertySetID,

                    32802,

                    MapiPropertyType.Integer);

     

                  thisview.PropertySet = extendedPropertySet;

    foreach (var v in svc.FindItems(WellKnownFolderName.Contacts, thisview))

                {

                    Contact contact = v as Contact;

                    ContactGroup contactGroup = v as ContactGroup;

                    v.Load();

     

     

                    if (contact != null)

                    {

                        Console.WriteLine("Contact: {0}", contact.DisplayName);

                        Console.WriteLine("Title: {0}",contact.CompleteName.Title);

                        Console.WriteLine("Notes: {0}", contact.Body.Text);

                        Console.WriteLine("Properties {0}", v.ExtendedProperties.Count);     

     

                        Contact zz = Contact.Bind(svc, new ItemId(contact.Id.UniqueId),extendedPropertySet);

     

                        foreach (ExtendedProperty extendedProperty in zz.ExtendedProperties)

                        {

                            Console.WriteLine("?: {0}",extendedProperty.Value);

                        }

     

    }

     

    But this doesn't work.

     

    Expected Result: is to get those extended properties.  I had it working once, but after playing around with this for a while I don't know what I did.

     

    Please enlighten me on either the proper way to do this or what is wrong with this code.

     

    Thank you,

    Dennis Bailey

    Friday, August 26, 2011 6:49 AM

Answers