首页 > 解决方案 > VSTO Outlook 如何在定期会议中的 AppointmentItems 链中获取上一个 AppointmentItem

问题描述

我目前正在为 AppointmentItem 开发 Outlook 插件。如果 AppointmentItem 是定期会议“链”的成员,我想检索/查找上一次会议的 AppointmentItem。我怎样才能做到这一点?

我想出了以下部分解决方案:

Outlook.AppointmentItem item = (Outlook.AppointmentItem)inspector.CurrentItem;
if (item.IsRecurring) {
    Outlook.RecurrencePattern pattern = item.GetRecurrencePattern(); 
    Outlook.OlRecurrenceType occurenceType = pattern.RecurrenceType;
    int dayFactor = 0;
    switch (occurenceType) {
        case Outlook.OlRecurrenceType.olRecursDaily:                            
           dayFactor = 1;
           break;
        case Outlook.OlRecurrenceType.olRecursWeekly:
        default:
           dayFactor = 7;
           break;
        // TODO handly all other cases of RecurrenceType
    }
    Outlook.AppointmentItem lastItem = pattern.GetOccurrence(item.StartInStartTimeZone.AddDays(-1*pattern.Interval*dayFactor));                         

但这仅处理极少数“简单”的情况。尤其是当涉及到计算时,例如每个月的第一个星期二,这对我来说太棘手了。有输入吗?此代码示例也可能有用:http ://www.outlookcode.com/codedetail.aspx?id=1414

标签: vstooutlook-addin

解决方案


不容易。您需要在代码中明确扩展该系列,同时考虑到重复模式和异常。

如果使用Redemption是一个选项,它的版本RDORecurrencePatternGetOccurrence方法允许传递一个整数索引(除了日期 a-la OOM)作为参数,因此您可以构建一个出现的数组。


推荐阅读