ews-java-api
ews-java-api copied to clipboard
Set Gender of contact
Hi,
can someone please post a sample on how to set the gender for a contact. I have no idea on how to do it, because contact.setGender() is not available.
Thanks for your help
Andi
Hi @talentfrei ,
I think there is no EWS-Contact Gener Property. You have to use/set/read extended properties.Try this code example:
ExtendedPropertyType gender = new ExtendedPropertyType();
gender.ExtendedFieldURI = new PathToExtendedFieldType();
gender.ExtendedFieldURI.PropertyTag = “0x3a4d”;
gender.ExtendedFieldURI.PropertyType = MapiPropertyTypeType.Short;
gender.Item = “0”;
You have to 'translate' it to Java, but it should be nearly the same....
See the gender documentaion: PidTagGender
Greetings/Grüße Jan
HI @OS-JaR,
thank you for your quick reply!I have already tried something similar to create a new contact with gender attribute. Sadly it is not working:
//New contact
Contact contact = new Contact(service);
//1st Try
ExtendedPropertyDefinition gender = new ExtendedPropertyDefinition(0x3a4d,MapiPropertyType.Short);
contact.setExtendedProperty(gender,1);
//2nd Try
ExtendedPropertyDefinition gender = new ExtendedPropertyDefinition(0x3a4d,MapiPropertyType.Short);
contact.getExtendedProperties().setExtendedProperty(gender, 1);
//Save Contact
contact.save();
I get error: The value of the extended property is inconsistent with its type
BR
Andi
//1st Try
ExtendedPropertyDefinition gender = new ExtendedPropertyDefinition(0x3a4d,MapiPropertyType.Short); contact.setExtendedProperty(gender,1);
this is how I usually do. It worked fine but now i note that the gender is not correctly displayed in outlook (2013). In a another version, an ID is displayed in place of the gender.
Now I'm lookingfor the best manner to deal with gender in EWS.