How to do paging with Exchange Web Services CalendarView

前端 未结 3 596
故里飘歌
故里飘歌 2021-02-07 12:20

If I do this:

_calendar = (CalendarFolder)Folder.Bind(_service, WellKnownFolderName.Calendar);

var findResults = _calendar.FindAppointments(
    new CalendarVie         


        
3条回答
  •  庸人自扰
    2021-02-07 13:01

    You can use ItemView and SearchFilter to query appointments:

    var itemView = new ItemView(100, 0);
    itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly,
        ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
    
    var filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And,
        new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Appointment"),
        new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, startDate),
        new SearchFilter.IsLessThan(AppointmentSchema.Start, endDate));
    
    bool moreAvailable = true;
    while (moreAvailable)
    {
        var result = _service.FindItems(WellKnownFolderName.Calendar, filter, itemView);
    
        foreach (var appointment in result.OfType())
        {
            DateTime start = appointment.Start;
            DateTime end = appointment.End;
            string subject = appointment.Subject;
    
            // ...
        }
    
        itemView.Offset += itemView.PageSize;
        moreAvailable = result.MoreAvailable;
    }
    

提交回复
热议问题