[英]How to delete the entire Exchange Calender activities using Java EWS api?
I have written the code as below where it deletes the Appointment having current date but is there a way where i can delete the entire Calendar Appointments in one shot. 我编写了以下代码,其中删除了具有当前日期的约会,但是有一种方法可以一次性删除整个日历约会。 Thanks in Advance
提前致谢
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;
}
Generally the two options you have is you can batch delete the Items that you return from FindItems (find appointments will expand the recurring appointments which if you want to delete all the Items you don't want to do just delete the Master and single instances instead see https://msdn.microsoft.com/en-us/library/office/dn626016(v=exchg.150).aspx#bk_deleteews ) 通常,您有两个选择,就是您可以批量删除从FindItems返回的项目(查找约会将扩展定期约会,如果要删除所有不想执行的项目,只需删除主实例和单个实例即可)参见https://msdn.microsoft.com/zh-cn/library/office/dn626016(v=exchg.150).aspx#bk_deleteews )
The other option would be to use the Empty Folder operation which should work in 2013 and above https://msdn.microsoft.com/en-us/library/office/ff709484%28v=exchg.150%29.aspx 另一种选择是使用“空文件夹”操作,该操作应在2013年及更高版本中运行https://msdn.microsoft.com/zh-cn/library/office/ff709484%28v=exchg.150%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.