【问题标题】:Adding Exception to Recurring Appointment Outlook向定期约会 Outlook 添加例外
【发布时间】:2016-05-19 04:57:51
【问题描述】:

我成功地以编程方式创建了定期约会。现在我想通过添加例外来增强它。我将此站点用作参考https://msdn.microsoft.com/en-us/library/office/ff184635.aspx,它会在Outlook.Exception myException = newPattern.Exceptions[1]; 中断

当我设置断点并检查 Exceptions.Count 时,如果有帮助,它就为零。

foreach (var exceptionOccurrence in appointment.RecurrenceRule.Exceptions)
{
    Outlook.AppointmentItem myInstance = outLookPattern.GetOccurrence(exceptionOccurrence.ExceptionDate);
    if (myInstance != null)
    {
        myInstance.Subject = "My Exception";
        myInstance.Save();
        Outlook.RecurrencePattern newPattern = appointmentItem.GetRecurrencePattern();

        var myException = newPattern.Exceptions[1];
        if (myException != null)
        {
            Outlook.AppointmentItem myNewInstance = myException.AppointmentItem;
            myNewInstance.Start = exceptionOccurrence.Appointment.Start;
            myNewInstance.End = exceptionOccurrence.Appointment.End;
            myNewInstance.Save();
        }
    }
}

【问题讨论】:

    标签: c# outlook


    【解决方案1】:

    使用 AppointmentItem.GetRecurrencePattern().GetOccurrence() 检索您要修改的特定重复实例 - 它返回与该事件相对应的 AppointmentItem,修改它并保存 (AppointmentItem.Save)。

    【讨论】:

    • 嗨@Dmitry,如果我想删除该事件有什么想法吗?我没有使用 .Save,而是使用了 .Delete(),但这并没有添加异常。
    • 嗨@Dmitry,我尝试了保存和删除。它确实会影响 Outlook 日历,但不会保存异常 =(
    • “它确实会影响 Outlook 日历”是什么意思?你的意思是你可以在 Outlook 中看到变化,但 Exceptions.Count 仍然 == 0?
    • 嗨德米特里,我可以看到前景的变化。当我简单地运行Outlook.RecurrencePattern pattern = item.GetRecurrencePattern(); var test = pattern.Exceptions; Exceptions.Count 仍然为零。
    • Outlook 对象模型因缓存旧的约会数据而臭名昭著。重新启动 Outlook 后是否看到更改?
    猜你喜欢
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多