我已经写了以下代码,该代码删除了具有当前日期的约会,但是有一种方法可以一次删除整个日历约会。预先感谢
epublic static HashSet<String> userEventEws(ExchangeService service) {
HashSet<String> listSubject = new HashSet<String>();
Calendar yesterday = Calendar.getInstance();
Calendar now = Calendar.getInstance();
yesterday.add(Calendar.DATE, -1);
now.add(Calendar.DATE, 1);
Date startDate = yesterday.getTime();
Date endDate = now.getTime();
try {
CalendarFolder calendarFolder = CalendarFolder.bind(service, WellKnownFolderName.Calendar, new PropertySet());
CalendarView cView = new CalendarView(startDate,endDate);
cView.setPropertySet(new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End));// we can set other properties
// as well depending upon our need.
FindItemsResults appointments = calendarFolder.findAppointments(cView);
List <Appointment>appList = appointments.getItems();
for (Appointment appointment : appList) {
listSubject.add(appointment.getSubject().trim());
appointment.delete(DeleteMode.HardDelete);
}
} catch (Exception e) {
e.printStackTrace();
}
return listSubject;
}
通常,您拥有的两个选项是您可以从Finditems删除您返回的项目(查找约会将扩展重复的约会,如果您想删除所有不删除所有项目想要做只删除主实例,而是请参阅https://msdn.microsoft.com/en-us/library/library/office/dn626016(V=EXCHG.150).aspx#bk_deleteews)
)另一个选项是使用空文件夹操作,该文件夹操作应在2013年和更高版本https://msdn.microsoft.com/en-us/library/library/ffkice/ff709484(v=exchg.150).aspx9.aspx