Search code examples
c#exchangewebservicesexchange-server-2010

Using EWS, how do I get a meeting room name if I have its email address?


I have a list of meeting room email addresses and I would like to get their names. How do I do that using EWS and a 2010 exchange server. The server does not seem to have SP1 though, so I cannot use ExchanceService.ResolveName. If I do, I get the message Method ResolveName is only valid for Exchange Server version Exchange2010_SP1 or later.

UPDATE:

Actually, I am using https://outlook.office365.com, so I am not too sure why I am getting the above error message when I try to use the ResolveName method.

UPDATE 2:

In fact, yes, it is possible to use ResolveName on office365. I was just passing the wrong server version when instanciating ExchangeSercice. I was passing ExchangeVersion.Exchange2010, but it is also possible to use ExchangeVersion.Exchange2010_SP1, ExchangeVersion.Exchange2010_SP2, etc.


Solution

  • You can use the ResolveName operation like below, to get the meeting room name:

        EmailAddressCollection roomLists = service.GetRoomLists();
        foreach (EmailAddress email in roomLists)
        {
            EmailAddress roomList = email.Address;
            PropertySet props = new PropertySet(BasePropertySet.FirstClassProperties);
            NameResolutionCollection nrCol = service.ResolveName(email.Address, ResolveNameSearchLocation.DirectoryOnly, true, props);
            foreach (NameResolution nr in nrCol)
            {
                Console.WriteLine(nr.Contact.DisplayName);
            }
        }