EWS - 从交换中拉出自动联系人联系人

时间:2014-09-10 08:29:18

标签: exchange-server exchangewebservices ews-managed-api

我试过谷歌搜索但没有找到任何明确的答案。 是否可以使用EWS Api从交换中拉出Autolist联系人?我知道我可以search contacts by name,但是我可以通过自动列表拉它们吗?

1 个答案:

答案 0 :(得分:2)

使用Exchange Service Managed API 2.0这应该可以解决问题:

private static void ListOwaAutocompleteCache(ExchangeService service, string email)
{
    var folderId = new FolderId(WellKnownFolderName.Root, email);
    var userConfig = UserConfiguration.Bind(service, "OWA.AutocompleteCache", folderId, UserConfigurationProperties.All);

    var xml = Encoding.UTF8.GetString(userConfig.XmlData);
    var xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(xml.Substring(1));
    var nodes = xmlDoc.SelectNodes("AutoCompleteCache/entry");
    foreach (XmlNode node in nodes)
    {
        Console.WriteLine(node.Attributes["displayName"].Value + ", " + node.Attributes["smtpAddr"].Value);
    }
}