Deleting Appointment Automatically When Expired

  • Thread starter Thread starter Orion Cochrane
  • Start date Start date
O

Orion Cochrane

Is there a way for Outlook to automatically delete an appointment when the
system time is >=End of Appointment? I want a prompt before deleting.

TIA
 
You would have to write code to do that, scanning your calendar folder on a
timer event or run manually from a macro or something like that.
 
Very slightly modified from an example from the Outlook VBA Help on
Items.Restrict. Always use the Object Browser to look for examples and
sample code:

Public Sub ApptDateCheck()
Dim myNamespace As Outlook.NameSpace
Dim myAppts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Dim i As Long
Dim DateStart As Date

DateStart = Date
Set myNamespace = Application.GetNamespace("MAPI")
Set myAppts = myNamespace.GetDefaultFolder(olFolderCalendar).Items
Set myItems = myAppts.Restrict("[End] < """ & DateStart & """")
For i = myItems.Count To 1 Step -1
Set myItem = myItems.Item(i)
If (myItem.Class = olAppointment) Then
myItem.Delete
End If
Next
End Sub
 
Back
Top