0
我能够使用下面的代码获得我的组织中可用的会议室,我需要获得特定会议室的预约,所以我使用了下面的代码it.`如何获得使用EWS JAVA API访问其他邮箱日历的权利
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("[email protected]", "zzzz");
service.setCredentials(credentials);
try {
System.out.println("Check");
service.autodiscoverUrl("[email protected]",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("[email protected]");
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中。
在此先感谢。
除了获得管理员权限之外,还有其他方法吗?因为它是公司办公室,我将无法获得管理员权限。你能否以其他方式暗示我 – Akshea 2015-02-26 09:45:48
你不需要管理员权限。您的帐户需要委派访问日历。另一种选择是,如果您只需查找房间何时免费且不需要实际阅读约会,则可以查看其忙/闲信息:https://msdn.microsoft.com/EN-US/library/办公室/ dn643673(v = exchg.150)的.aspx。这通常不需要任何特殊的权限。 – 2015-02-26 14:17:01