2

I am able to get the meeting rooms available in my Organisation using the below code, I need to get the appointment of the particular room, so i have used the below code for it.`

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
    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("MeetingRoom1",ResolveNameSearchLocation.DirectoryOnly, true);
    System.out.println("nameResolutions==="+nameResolutions.getCount());

    for(NameResolution nameResolution : nameResolutions)
    {
        System.out.println("NAME==="+nameResolution.getContact().getDisplayName());


    }
    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("meetingroom-1@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();
       }
}`

If i execute this code, i am able to get the list of all meeting room available in my Organisation with name MeetingRoom1, then i am trying to access the particular meetingroom-1@yy.com to get the appointments for that room ,but throwing some exception like below.

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)

I guess it may be due to that i dont have access rights to access the calendar of the meeting room. How to proceed further to get the appointment. please help me .I need it in EWS-JAVA API.

Thanks in advance.

Akshea
  • 257
  • 1
  • 3
  • 10

1 Answers1

2

The account that your code is running under needs delegate access to the meeting room's calendar in order for that code to work. That's something that your admins need to configure for you on the server.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Is there any other way other than getting admin rights. As , it is corporate office, i will not be able to get admin rights. Can you suggest me some other way – Akshea Feb 26 '15 at 09:45
  • 1
    You don't need admin rights. Your account needs delegate access to the calendar. The other option if you just need to find when the rooms are free and don't need to actually read the appointments themselves is to check their free/busy information: https://msdn.microsoft.com/EN-US/library/office/dn643673(v=exchg.150).aspx. This doesn't usually require any special permissions. – Jason Johnston Feb 26 '15 at 14:17