我想达到与此问题中提到的完全相同的东西,但在java中:How to set the contact title using Exchange Web Services Managed API
我正在使用EWS Java API 1.2(http://archive.msdn.microsoft.com/ewsjavaapi)。 我可以创建与API中公开的所有字段的联系人,但不能创建标题(或Email1DisplayName)。我尝试了这些组合(没有错误,但在Outlook中查看时,标题在创建的联系人中保持为空):
contact.setExtendedProperty(new ExtendedPropertyDefinition(UUID.fromString("00062004-0000-0000-C000-000000000046"), 0x3A45, MapiPropertyType.String), value);
contact.setExtendedProperty(new ExtendedPropertyDefinition((UUID) null, 0x3A45, MapiPropertyType.String), value);
contact.setExtendedProperty(new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String), value);
答案 0 :(得分:0)
好的我以前不知道我做错了什么,但我的问题中的一个选项确实适用于标题。这是完整的示例代码(我希望之前有过):
ExchangeService mailbox = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
mailbox.setUrl(new URL("https://remote.domain.com/EWS/exchange.asmx").toURI());
ExchangeCredentials credentials = new WebCredentials("user.name", "password", "domain");
mailbox.setCredentials(credentials);
ExtendedPropertyDefinition titlePropDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
Contact c = new Contact(mailbox);
c.setGivenName("GivenName");
c.setSurname("Surname");
c.getEmailAddresses().setEmailAddress(EmailAddressKey.EmailAddress1, new EmailAddress("asdf@asdf.com"));
c.setExtendedProperty(titlePropDef, "TitleXYZ");
c.save(WellKnownFolderName.Contacts);
Contact result = (Contact) mailbox.findItems(WellKnownFolderName.Contacts, new ItemView(1)).iterator().next();
PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties);
propertySet.add(titlePropDef);
result = Contact.bind(mailbox, result.getId(), propertySet);
System.out.println("count: " + result.getExtendedProperties().getCount());
for(ExtendedProperty p : result.getExtendedProperties())
{
System.out.println(p.toString());
}