未在EWS API中获取房间列表

时间:2017-02-27 10:26:15

标签: c# asp.net-mvc exchangewebservices

我试图通过EWS api 2.0获取房间列表,但获取列表0。

这是我的示例代码:

var RoomList = new List<RoomListData>();
List<string> userLists = new List<string>();
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);

service.Credentials = new NetworkCredential("username", "password");
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

service.Url = new Uri("**************/ews/exchange.asmx");
EmailAddressCollection myRoomLists = service.GetRoomLists();
//Display the room lists.
foreach (EmailAddress address in myRoomLists)
{
    RoomList.Add(new RoomListData()
    {
        Address = address.Address,
        Id = address.Id,
        MailboxType = address.MailboxType,
        Name = address.Name,
        RoutingType = address.RoutingType,

    });
}
response.RoomList = RoomList;

1 个答案:

答案 0 :(得分:2)

在Exchange中,默认情况下没有配置空间列表,您需要使用New-DistributionGroup -RoomList switch https://technet.microsoft.com/en-us/library/aa998856(v=exchg.160).aspx创建RoomList。人们常常将您在GAL中看到的AddressBook视图(EG All Rooms)与RoomLists混淆,这些并不是同一件事。