簡體   English   中英

如何使用Java EWS API刪除整個Exchange Calender活動?

[英]How to delete the entire Exchange Calender activities using Java EWS api?

我編寫了以下代碼,其中刪除了具有當前日期的約會,但是有一種方法可以一次性刪除整個日歷約會。 提前致謝

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/zh-cn/library/office/dn626016(v=exchg.150).aspx#bk_deleteews

另一種選擇是使用“空文件夾”操作,該操作應在2013年及更高版本中運行https://msdn.microsoft.com/zh-cn/library/office/ff709484%28v=exchg.150%29.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM