在重复约会Outlook中添加例外

时间:2016-05-18 14:17:37

标签: c# outlook

我成功地以编程方式创建了定期约会。现在我想通过添加例外来增强它。我使用此网站作为参考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();
        }
    }
}

1 个答案:

答案 0 :(得分:1)

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