EWS: Accessing an appointments recurrence pattern

妖精的绣舞 提交于 2019-12-11 13:31:37

问题


I am trying to get the recurrence pattern associated with the appointment in the below code. When I debug the code and expand the microsoftAppointment.Recurrence property in the Locals Window I can see a nested class called [Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern] that has the information in it I need but I can not figure out how to access this information in my code. It is obviously in memory I just don't understand why I can't read it in code during run time. I have tried FindAppointments but that only returns Recurrence as null.

FindItemsResults<Item> findResults = exchangeService.FindItems(WellKnownFolderName.Calendar, new ItemView(folderCount));

exchangeService.LoadPropertiesForItems(findResults.Items, new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Body, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Body, AppointmentSchema.IsRecurring, AppointmentSchema.Recurrence));

foreach (var v in findResults.Items)
{
    Microsoft.Exchange.WebServices.Data.Appointment microsoftAppointment = v as Microsoft.Exchange.WebServices.Data.Appointment;

    if (microsoftAppointment.IsRecurring)
    {
    ...
    }
}

回答1:


The following casts ended up working for me. You can skip the Interval Pattern step but I did a switch after that to find the type (weekly, daily, etc.) so I could correctly cast the interval pattern.

Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern pattern = (Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern)microsoftAppointment.Recurrence;
weeklyPattern = (Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern) pattern;


来源:https://stackoverflow.com/questions/10656136/ews-accessing-an-appointments-recurrence-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!