none
[E2010][EWS-XML][JAVA]How to get the properties of meeting rooms in Exchange 2010 using EWS Java API RRS feed

  • Question

  • When you look at meeting room properties in Outlook 2010, you can see 'City', 'Country/Region' and 'Department' information.

    Is there any way to get this information using EWS Java API? 


    Thursday, August 2, 2012 11:30 AM

Answers

  • You need to use the ResolveName operation and specify to return the Contact information from Active Directory in the Java EWS api you should be able to use the resolveName Method from the ExchangeService class eg something like

    NameResolutionCollection nameResolutions = service.resolveName("Meeting Room 1",ResolveNameSearchLocation.DirectoryOnly, true);
    System.out.println("nameResolutions==="+nameResolutions.getCount());
    
    for(NameResolution nameResolution : nameResolutions)
    {
      	System.out.println("NAME==="+nameResolution.getContact().getName());
    
    
    }
    

    You should then be able to get what you want from the Contact object

    Cheers
    Glen

    • Marked as answer by Erkki.Solala Friday, August 3, 2012 8:11 AM
    Friday, August 3, 2012 6:41 AM

All replies

  • You need to use the ResolveName operation and specify to return the Contact information from Active Directory in the Java EWS api you should be able to use the resolveName Method from the ExchangeService class eg something like

    NameResolutionCollection nameResolutions = service.resolveName("Meeting Room 1",ResolveNameSearchLocation.DirectoryOnly, true);
    System.out.println("nameResolutions==="+nameResolutions.getCount());
    
    for(NameResolution nameResolution : nameResolutions)
    {
      	System.out.println("NAME==="+nameResolution.getContact().getName());
    
    
    }
    

    You should then be able to get what you want from the Contact object

    Cheers
    Glen

    • Marked as answer by Erkki.Solala Friday, August 3, 2012 8:11 AM
    Friday, August 3, 2012 6:41 AM
  • Many thanks for help.

    I was able to get the necessary information from Contact.


    Friday, August 3, 2012 8:11 AM
  • Hi Glen,

    Thanks for giving this code...With this code, i am able to fetch the name of the meeting rooms available.But i want to know, how to get the appointment of the particular room like what time rooms are booked along with date. Can, you please help me in it. I am using ews-java api

    Thanks,

    Akshea

    Monday, February 16, 2015 11:45 AM
  • There are two ways you could do that just use FindItem to query the Calendar Folder involved see "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in https://github.com/OfficeDev/ews-java-api

    The other method you could use if you have multiple mailboxes you want to do this on is use the FreeBusy time via GetUserAvailabilty see the "Availability Service" section in the above link

    Cheers
    Glen

    Tuesday, February 17, 2015 12:24 AM
  • Hi Glen,

    I am able to understand what u have said, but do not know how to implement it with meeting rooms....

    If i am implementing "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in ews-java-api, as you have mentioned above, i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

    static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
    
    	public static void main(String[] args) throws Exception {
    		// TODO Auto-generated method stub
    		
    		ExchangeCredentials credentials = new WebCredentials("xxx@yy.com", "zzzz");
    		service.setCredentials(credentials);
    		try {
    			System.out.println("Check");
    			service.autodiscoverUrl("xxx@yy.com",new RedirectionUrlCallback());
    			
    			
    
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		
    		
    		NameResolutionCollection nameResolutions = service.resolveName("SDB1",ResolveNameSearchLocation.DirectoryOnly, true);
    		System.out.println("nameResolutions==="+nameResolutions.getCount());
    
    		for(NameResolution nameResolution : nameResolutions)
    		{
    		  	System.out.println("NAME==="+nameResolution.getContact().getDisplayName());
    
    
    		}
    	}

    The above code gives me the output like, the meeting room in my organization with word SDB1 are

    Output:

    nameResolutions===2

    NAME===SDB1- TELCON - 1

    NAME===SDB1-TELCON - 2

     for. eg. I need to know today at what are the appointments in the room SDB1-TELCON2 and who all have booked the room.

    I do not know how to implement for the meeting room can you please help me how to give it.

    Thanks in advance.


    • Edited by Akshea Tuesday, February 17, 2015 5:24 AM
    Tuesday, February 17, 2015 5:20 AM
  • >i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

    You use exactly the same code but all you need to do is use FolderId class overload to specify Mailbox you want to access eg

                FolderId Calendar = new FolderId(WellKnownFolderName.Calendar, "Mailbox@domain");
                service.FindAppointments(Calendar,.....
    Cheers
    Glen

    Wednesday, February 18, 2015 3:21 AM
  • Hi Glen,

    Thanks, for your response....

    What is that Mailbox@domain ? Is it the meeting room email id?

    Wednesday, February 18, 2015 4:20 AM
  • Yes it needs to be the primarySMTP address of the Mailbox you want to access
    Wednesday, February 18, 2015 4:35 AM
  • How could i get that primarySMTP address?
    Wednesday, February 18, 2015 5:00 AM
  • Suggest me some sample of it
    Wednesday, February 18, 2015 5:02 AM
  • Is it like my meeting room email id? SDB1-TELCON2@yy.com?

    Wednesday, February 18, 2015 5:16 AM
  • Hi Glen,

    Along with the previous code mentioned, i have added the below code to get meeting room appointment, but it throws the following exception.

    Exception in thread "main" microsoft.exchange.webservices.data.ServiceResponseException: The specified folder could not be found in the store.
    	at microsoft.exchange.webservices.data.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:262)
    	at microsoft.exchange.webservices.data.ServiceResponse.throwIfNecessary(ServiceResponse.java:251)
    	at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:146)
    	at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:807)
    	at microsoft.exchange.webservices.data.ExchangeService.findAppointments(ExchangeService.java:1089)
    	at com.hcl.GetRoomClass.main(GetRoomClass.java:58)

    Here is my code:

    Date startDate = new Date();
    		
    		Calendar cal = Calendar.getInstance();
    		cal.setTime(startDate);
    		cal.add(Calendar.DATE, 30); // add 10 days
    		 
    		Date endDate = cal.getTime();
    		   Mailbox meetingMailbox = new Mailbox("SDB1-TELCON2@yy.com");
               FolderId CalendarId = new FolderId(WellKnownFolderName.Calendar, meetingMailbox);
               CalendarView cView = new CalendarView(startDate, endDate);
               FindItemsResults<Appointment> appointments = service.findAppointments(CalendarId, cView);
               for (Appointment a : appointments)
               {
                   System.out.println("Subject: " + a.getSubject().toString() + " ");
                   System.out.println("Start: " + a.getStart().toString() + " ");
                   System.out.println("End: " + a.getEnd().toString());
                   System.out.println();
               }

    What is the problem? Am i not able to access the meeting room calendar.

    Wednesday, February 18, 2015 6:28 AM
  • HI glen, 

    Can you please help in below exception caused

    Friday, February 20, 2015 6:43 AM
  • That error mean you don't have rights to the Mailbox Folder in question you need to grant the rights via either Add-MailboxPermission or Add-MailboxFolderPermission or use EWS Impersonation (Note you need to be able to open the Calendar folder in outlook using whatever user you running the code as, Admin rights mean nothing).

    Cheers

    Glen

    Sunday, February 22, 2015 10:36 PM
  • Hi Glen,

    Can i get any sample how to grant the rights via Add-Mailbox Permission using ews java api.....I am not having admin rights to use Impersonation. Please help me.

    Thanks in advance

    Monday, February 23, 2015 7:26 AM
  • Hi Glen,

    can you please help me in it.

    Wednesday, February 25, 2015 9:59 AM