none
Getting value of Hobby field using Exchange EWS RRS feed

  • Question

  • Hi,

    I am using EWS excahnge API with axis and accessing Exchange_2007_SP1 server.


    In a standard outlook contact there are 4 fields with the names User Field 1 ....4.
    We can update and access those fields using extended properties.

    We also want to get the value of Hobby field.  As this field is not exposed in the EWS api,   We tried the same way of extended property as we did for user fields.  but its not working.  When We add the the value of hobby, it goes as an extended property but it is not shown on the outlook.

    We have given the propertyId of this as - 14915 (which we got from outlookspy)

    Here is the code snipet

    ExchangeServiceBindingStub mEWSservice;

    // List to hold extended properties of the contact - in our case User1 and Hobbies
    ArrayList<ExtendedPropertyType> listExtendedProperty = new ArrayList<ExtendedPropertyType>();

    // Create a contact object
    ContactItemType contact = new ContactItemType();
    contact.setItemClass("IPM.Contact");

    contact.setDisplayName("MyName");

    // Set value of User1 field


    PathToExtendedFieldType extendedFieldURI = new PathToExtendedFieldType();
    extendedFieldURI.setDistinguishedPropertySetId(DistinguishedPropertySetType.PublicStrings);
    extendedFieldURI.setPropertyId(32847);
    ExtendedPropertyType extendedProperty = new ExtendedPropertyType();
    extendedProperty.setExtendedFieldURI(extendedFieldURI);  
    extendedProperty.setValue("Value for User1");
    listExtendedProperty.add(extendedProperty);

    // Set value of Hobby field
    PathToExtendedFieldType extendedFieldURI = new PathToExtendedFieldType();
    extendedFieldURI.setDistinguishedPropertySetId(DistinguishedPropertySetType.PublicStrings);
    extendedFieldURI.setPropertyId(14915);
    ExtendedPropertyType extendedProperty = new ExtendedPropertyType();
    extendedProperty.setExtendedFieldURI(extendedFieldURI);  
    extendedProperty.setValue("Reading");
    listExtendedProperty.add(extendedProperty);


    contact.setExtendedProperty(listExtendedProperty.toArray(new ExtendedPropertyType[listExtendedProperty.size()]));
    ContactItemType[] contacts = listContacts.toArray(new ContactItemType[listContacts.size()]);

    // Build CreateItemType and set the Contact
    CreateItemType createItemrequest = new CreateItemType();
    DistinguishedFolderIdType distinguishedFolder = new DistinguishedFolderIdType();
    NonEmptyArrayOfAllItemsType arrayItems = new NonEmptyArrayOfAllItemsType();
    distinguishedFolder.setId(DistinguishedFolderIdNameType.contacts);
    arrayItems.setContact(contacts);
    TargetFolderIdType folderIdType = new TargetFolderIdType();
    folderIdType.setDistinguishedFolderId(distinguishedFolder);
    createItemrequest.setSavedItemFolderId(folderIdType);  
    createItemrequest.setItems(arrayItems);
      
    CreateItemResponseTypeHolder createItemResponse = new CreateItemResponseTypeHolder();
    ServerVersionInfoHolder exchangeServerVersion = new ServerVersionInfoHolder();

    mEWSservice.createItem(createItemrequest, null, null, null, requestVersion, createItemResponse, exchangeServerVersion);

    ===

    On executing this code, the contact gets created and in outlook we can see the displayname and user1 field values.  But we don't see the value of the Hobby field in outlook.

    Lateron when we retrieve the Hobby field using EWS API, we get the value of Hobby property that was set during add operation.So the problem that we face is that  the Hobby field that we  set during add operation is not displayed in Outlook.

    Can anyone help me on this.

    Thank you.

    - Regards

    - Bhagya
     



    Monday, March 28, 2011 2:31 PM

All replies

  • Extended properties you add via EWS wont appear in the Outlook fields chooser if you have a read of David's response in http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/2a98b4ab-0fbc-4863-8303-48711a18a050/ it explains the reason why further on in the thread there are some suggested workarounds for this.

    Cheers
    Glen

    Tuesday, March 29, 2011 2:18 AM
  • Hi Glen,

    Thanks for your reply but unfortunately it does not seem to answer my question.  Let me simplify my question.

    Using Outlook, we give value to Hobby field.  Now we want to retrieve it using EWS api.  As there is no direct method to access this field we tried to access it as extended property.  but no sucess.  Whereas the same works fine for user1, user2, user3, user4 fields.

    Also we are facing the problem vice-versa(adding from EWS api and not able to see its value in outlook)

    Please help us on the same.

    Thank you.

    Regards

    -Bhagya

    Tuesday, March 29, 2011 4:57 AM
  • Okay it sounds like you don't quite understand the difference between named properties and a tagged property firstly have a read of http://msdn.microsoft.com/en-us/library/cc815528.aspx . The hobbies property is a tagged property so you would define this as

    PathToExtendedFieldType hobbies = new PathToExtendedFieldType();
    hobbies.PropertyTag = "0x3A43";
    hobbies.PropertyType = MapiPropertyTypeType.String;
    

    Cheers
    Glen 

     

    Tuesday, March 29, 2011 6:07 AM
  • Hi Glen,

    Thanks again.

    We changed the code as per your suggestion and set the PropertyTag instead of propertyId.  But on execution, we got an exception.

    The code snipet is -

    PathToExtendedFieldType extendedFieldURI = new PathToExtendedFieldType();
    extendedFieldURI.setDistinguishedPropertySetId(DistinguishedPropertySetType.PublicStrings);
    extendedFieldURI.setPropertyTag(new PropertyTagType(new UnsignedShort(0x3A43)));
    extendedFieldURI.setPropertyType(MapiPropertyTypeType.String);
    ExtendedPropertyType extendedProperty = new ExtendedPropertyType();
    extendedProperty.setExtendedFieldURI(extendedFieldURI); 
    extendedProperty.setValue("Reading");

    and the exception that I got is -

    (AxisFault): The request failed schema validation: The 'PropertyTag' attribute is invalid - The value 'com.microsoft.schemas.exchange.services._2006.types.PropertyTagType@3a44' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:PropertyTagType'

    Please let us know whether we are missing something.

    Thank you.

    Regards.

    - Bhagya 

    Tuesday, March 29, 2011 10:44 AM
  • I don't use AXIS the code i gave for .NET proxies that works okay it looks like a problem with they way you treating the datatype maybe http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/4224d68a-8de3-4210-a7b7-abbddb209f69/ will help you should treat the ropertyTag as a string

    cheers
    Glen

    Wednesday, March 30, 2011 2:15 AM