【发布时间】:2016-12-12 13:55:00
【问题描述】:
谁能建议我如何连接到 Exchange Server 2010(客户端访问,集线器)并从公共文件夹中检索联系人。我有 Exchange Server 2010,我需要通过我的 asp.net/C# 应用程序连接到 Exchange Server,并且我正在使用 EWS Managed API 2.0 从 Exchange 2010 公用文件夹数据库中连接和检索联系人。
挑战是: 我们如何使用 EWS API 检索自定义联系人字段?有没有办法实现和检索已在 Exchange 2010 公用文件夹数据库的联系人中设置的自定义字段。
如果有人能建议我如何检索在 Exchange Server 2010 的公用文件夹的 OWA 联系人表单中不可见的联系人及其自定义字段,那将是非常有帮助的。
是否有任何解决方法来实现此功能或任何替代方式。请推荐我?
谢谢。
这是我的代码:
string ExchangeContactFolder = Configuration.ExchangeContactFolder;
Folder ContactFolder = GetTopLevelFolder(_service, ExchangeContactFolder);
ItemView itemView = new ItemView(int.MaxValue);
FindItemsResults<Item> searchResults = _service.FindItems(ContactFolder.Id, itemView);
int totalContacts = searchResults.TotalCount;
//Setting properties for Custom Fields.
Guid FacebookGuid = new Guid("{a49b36f1-7895-4637-98ec-1ca35a345095}");
var FacebookAddress = new ExtendedPropertyDefinition(FacebookGuid, "Facebook", MapiPropertyType.String);
itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
itemView.PropertySet.Add(FacebookAddress);
FindItemsResults<Item> contactItems = _service.FindItems(ContactFolder.Id, view);
foreach (Item item in contactItems)
{
if (item is Contact)
{
string strFacebookAddress = string.Empty;
contact.GetLoadedPropertyDefinitions();
//item.TryGetProperty(FacebookAddress, out strFacebookAddress);
contact.TryGetProperty(FacebookAddress, out strFacebookAddress);
strContacts.Add(bcSearch);
}
}
}
return strContacts;
【问题讨论】:
-
所以你说的是公用文件夹,但你的代码只是访问本地联系人文件夹?那样有用吗 ?您是否在问如何访问特定的公用文件夹?在这种情况下可以尝试逐步提出您的问题
-
嗨@GlenScales,我可以从配置文件中提到的公共文件夹中检索联系人,但我只检索默认的exchange 2010 联系人字段。我无法检索联系人的自定义字段。那么如何从联系人中检索自定义字段?
-
您发布的代码不会返回 foreach 循环中的属性,因为您没有请求它们,例如您已经定义并且 ItemView 调用了 itemView 但您没有在第二个 FindItems 方法调用中使用它(您使用一个名为 view 的变量)。也不要使用 int.Max 值,您应该将其设置为 1000 并对结果进行分页。我的第一个建议是清理您发布的示例,以便您可以使用一个搜索和一个属性集。
标签: asp.net exchange-server exchangewebservices exchange-server-2010