4

我在 Outlook 中有一个系列,但有一些例外。我想做的是从这个系列中删除所有例外。有谁知道是否有办法做到这一点?由于例外列表是只读的,我尝试清除重复模式并重新应用所有值,而不是例外列表,如下所示:

Dim tRType As OlRecurrenceType
Dim tRPSD As Date
Dim tRPED As Date
Dim tST As Date
Dim tET As Date
Dim tOcc As Integer
Dim tInterval As Integer

tRType = oAppointmentItem.GetRecurrencePattern.RecurrenceType
tRPSD = oAppointmentItem.GetRecurrencePattern.PatternStartDate
tRPED = oAppointmentItem.GetRecurrencePattern.PatternEndDate
tST = oAppointmentItem.GetRecurrencePattern.startTime
tET = oAppointmentItem.GetRecurrencePattern.endTime
tOcc = oAppointmentItem.GetRecurrencePattern.Occurrences
tInterval = oAppointmentItem.GetRecurrencePattern.Interval

oAppointmentItem.ClearRecurrencePattern
' This save throws an error. 
'oAppointmentItem.Save

' Make this call to flip to reccurring...
oAppointmentItem.GetRecurrencePattern
oAppointmentItem.GetRecurrencePattern.RecurrenceType = tRType
oAppointmentItem.GetRecurrencePattern.PatternStartDate = tRPSD
oAppointmentItem.GetRecurrencePattern.PatternEndDate = tRPED
oAppointmentItem.GetRecurrencePattern.startTime = tST
oAppointmentItem.GetRecurrencePattern.endTime = tET
oAppointmentItem.GetRecurrencePattern.Occurrences = tOcc
oAppointmentItem.GetRecurrencePattern.Interval = tInterval

到目前为止,我对这种方法没有运气。一旦调用 ClearRecurrencePattern,所有数据都无法更新(或者无论如何都不会保留),这就是我尝试保存但它不起作用的原因。必须有更好的方法,我只是想念它。

我还考虑过制作约会项目的完整副本,然后删除/重新添加,但是,如果可能的话,我想避免这种情况。

4

1 回答 1

1

我找到了答案,如果有人需要,我会在这里发布。您可以修改模式结束时间(我假设开始时间)以使其清除例外列表。下面的代码会导致从系列中删除所有异常。

Dim tEndDate As Date
Dim currentEndDate As Date
Dim dateInterval As Double
currentEndDate = oAppointmentItem.GetRecurrencePattern.PatternEndDate
tEndDate = oAppointmentItem.GetRecurrencePattern.PatternEndDate
' Add a year to the end date so we can force the exceptions to remove.
DateAdd "yyyy", 1, tEndDate
oAppointmentItem.GetRecurrencePattern.PatternEndDate = tEndDate
oAppointmentItem.GetRecurrencePattern.PatternEndDate = currentEndDate
于 2011-01-11T15:15:27.577 回答