如何使用 Exchange Web 服务托管 API 设置联系人头衔
我正在尝试使用 EWS API 创建新联系人。我可以设置除联系人标题属性之外的所有所需值。我尝试了代码:
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();
我没有收到错误,但是当我检查 Outlook 2010 中的标题字段时,它是空的。我正在使用 Exchange 2010。
您知道我做错了什么吗?
亲切的问候
福尔克马尔
I'm trying to create a new contact using the EWS API. I can set all the values i needed except the contact 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'm not getting an error but when i check the title field in outlook 2010, it's empty. I’m using Exchange 2010.
Any ideas what i did wrong?
Kind regards
Volkmar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短回答
创建扩展属性定义时,不要使用指定
propertySetId
的构造函数,而不是使用上面的代码。相反,应像这样构造它:更长的答案
您从 Microsoft 获得的参考资料很有趣。通过阅读 Inside Microsoft Exchange Server 2007 Web Services 中有关扩展属性的章节,我一直认为对于不在自定义范围内的扩展属性(低于 0x8000 的属性),在引用它们时您会忽略 propertySetId,因此有趣的是那个页面,微软似乎暗示你会使用它。
无论如何,Inside Microsoft Exchange Server 2007 Web Services 有一个免费附录(附录 C),其中还记录了扩展属性,网址为 http://www.microsoft.com/mspress/companion/9780735623927/ 可能比有关何时使用 propertySetId 和何时不使用的 Microsoft 页面更清楚。
http://msdn.microsoft.com/en-us/library/cc433490(EXCHG.80).aspx
Short Answer
When creating the extended property definition, instead of the code you have above, don't use the constructor where you specify the
propertySetId
. Instead, construct it like this:Longer Answer
That reference you have from Microsoft is interesting. From reading the chapter about extended prorperties in Inside Microsoft Exchange Server 2007 Web Services, I always thought that for extended properties not in the custom range (those below 0x8000), you'd leave out the propertySetId when referencing them, so it's interesting that on that page, Microsoft seems to imply you'd use it.
For what it's worth, there's a freely available appendix (Appendix C) to Inside Microsoft Exchange Server 2007 Web Services that also documents extended properties at http://www.microsoft.com/mspress/companion/9780735623927/ that might be clearer than that Microsoft page on when to use propertySetId and when not to.
There's also a more-accurate list of properties and their corresponding property sets at http://msdn.microsoft.com/en-us/library/cc433490(EXCHG.80).aspx