EWS:访问约会重复发生模式

时间:2012-05-18 16:11:43

标签: c# exchangewebservices

我试图在下面的代码中获得与约会相关的重复发生模式。当我调试代码并在Locals窗口中展开microsoftAppointment.Recurrence属性时,我可以看到一个名为[Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern]的嵌套类,其中包含我需要的信息,但我无法弄清楚如何在我的代码中访问此信息。显然在内存中我只是不明白为什么在运行时我无法在代码中读取它。我尝试过FindAppointments,但只返回Recurrence为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 个答案:

答案 0 :(得分:2)

以下剧组最终为我工作。你可以跳过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;