Reputation: 540
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)
{
...
}
}
Upvotes: 2
Views: 2302
Reputation: 540
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;
Upvotes: 2