我可以使用以下代码在我的组织中获得会议室,我需要预约特定房间,所以我使用了以下代码。
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();
}
}`
如果我执行此代码,我可以获取名为MeetingRoom1的组织中可用的所有会议室列表,然后我尝试访问特定的meetingroom-1@yy.com以获取该会议室的约会,但是如下所示抛出一些异常。
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)
我想这可能是因为我没有访问会议室日历的访问权限。如何进一步预约。请帮帮我。我需要它在EWS-JAVA API中。
提前致谢。
答案 0 :(得分:1)
您的代码运行的帐户需要委派对会议室日历的访问权限才能使该代码生效。这是管理员需要在服务器上为您配置的内容。