我想实现与这个问题完全相同的事情,但是在java中:如何使用 Exchange Web 服务托管 API 设置联系人头衔 https://stackoverflow.com/questions/4863364/how-to-set-the-contact-title-using-exchange-web-services-managed-api
我正在使用 EWS Java API 1.2 (http://archive.msdn.microsoft.com/ewsjavaapi 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);
好吧,我不知道我之前做错了什么,但我的问题中的选项之一确实适用于标题。这是完整的示例代码(我希望我之前有过):
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("[email protected] /cdn-cgi/l/email-protection"));
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());
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)