我成功地以编程方式创建了定期约会。现在我想通过添加例外来增强它。我使用此网站作为参考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();
}
}
}
答案 0 :(得分:1)
使用AppointmentItem.GetRecurrencePattern().GetOccurrence()
检索要修改的特定重复实例 - 它返回与该事件对应的AppointmentItem
,修改它并保存(AppointmentItem.Save
)。