How to set a contact header using the Exchange Web Services managed APIs

I am trying to create a new contact using the EWS API. I can set all the necessary values, except for the title property. I tried the code:

oContact = new Contact(oService); oContact.GivenName = "John"; oContact.Surname = "Doe"; oContact.Displayname = oContact.Surname; // set the title property as extended property // reference: http://msdn.microsoft.com/en-us/library/gg274394.aspx ExtendedPropertyDefinition oTitleProp = new ExtendedPropertyDefinition( new Guid("{00062004-0000-0000-C000-000000000046}"), 0x3A45, MapiPropertyType.String); oContact.SetExtendedProperty(oTitleProp, "Mr."); oContact.Save(); 

I do not receive an error message, but when I check the header field in Outlook 2010, it is empty. I am using Exchange 2010.

Any ideas what I did wrong?

Yours faithfully

Volkmer

+4
source share
1 answer

Short answer

When creating an extended property definition instead of the code above, do not use the constructor in which you specify propertySetId . Instead, create it as follows:

 ExtendedPropertyDefinition oTitleProp = new ExtendedPropertyDefinition( 0x3A45, MapiPropertyType.String); 

Longer answer

This link you received from Microsoft is interesting. After reading the chapter on advanced options inside Microsoft Exchange Server 2007 internal web services, I always thought that for advanced properties not in the user range (below 0x8000) you should leave the SetId property at their reference, so it’s interesting that on this page Microsoft seems to , implies that you use it.

Why is there a freely available Microsoft Exchange Server 2007 internal web services application (Appendix C) that also documents advanced features at http://www.microsoft.com/mspress/companion/9780735623927/ , which may be sharper than this Microsoft page when to use the SetId property and when not to.

There is also a more accurate list of properties and their corresponding property sets at http://msdn.microsoft.com/en-us/library/cc433490(EXCHG.80).aspx

+6
source

Source: https://habr.com/ru/post/1337947/


All Articles