我可以使用 Outlook 对象模型查看全局地址簿,但无论如何使用 csharp 的 Outlook 对象模型我可以获得一个人的以下属性:
城市、州、国家/地区
别名
标题
电话
我似乎无法在 AddressEntry 对象上找到这些属性。
编辑:我在这里开始了赏金。我使用 LDAP 查询完成了这项工作,但它们太痛苦了。令我震惊的是 Outlook 的简单 api 不支持此功能。我想看看是否有其他人可以正常工作或者可以解释/证明为什么 Outlook 不支持此功能
使用 Microsoft.Office.Interop.Outlook
您需要使用 ExchangeUser 对象和 AddressEntry 对象上的 GetExchangeUser 方法。
using System;
using Microsoft.Office.Interop.Outlook;
static class Program
{
static void Main(string[] args)
{
ExchangeUser oExUser;
Application app = new Microsoft.Office.Interop.Outlook.Application();
foreach (AddressList addressList in app.Session.AddressLists)
{
if (addressList.Name == "Global Address List")
{
foreach (AddressEntry item in addressList.AddressEntries)
{
Console.WriteLine(item.Address);
oExUser = item.GetExchangeUser();
if (oExUser != null)
{
Console.WriteLine(oExUser.FirstName);
Console.WriteLine(oExUser.LastName);
Console.WriteLine(oExUser.StreetAddress);
Console.WriteLine(oExUser.CompanyName);
Console.WriteLine(oExUser.Department);
Console.WriteLine(oExUser.OfficeLocation);
Console.WriteLine(oExUser.JobTitle);
}
Console.WriteLine();
}
}
}
Console.Read();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)