2011-01-10 67 views
4

我有一系列的Outlook,但有一些例外。我想要做的是從本系列中刪除所有例外。有誰知道是否有辦法做到這一點?由於例外列表是隻讀的我已經試過清除重複模式,並重新將所有的值SANS這樣的例外列表中:刪除系列的例外

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,所有數據都不能更新(或者不會持續),這就是爲什麼我嘗試了Save但它不起作用。必須有更好的方法,我只是想念它。

我也想過做一個預約項目的完整副本,然後刪除/重新添加,但是,我想盡可能避免這種情況。

回答

1

我找到了答案,並將其發佈到這裏以防萬一需要。您可以修改patternendtime(以及我假定的開始時間)以使其清除例外列表。下面的代碼會導致從系列中刪除所有異常。

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 
+1

應該指出,這清除*所有*例外。 – 2011-12-11 06:08:30