PDA

View Full Version : Macro to delete Calendar Entries w/Attachments



Paul_Hossler
06-19-2008, 11:25 AM
Does any one have an Outlook macro that I can run against my Calendar that would optionally:

1. Delete all entries that have attachments prior to an input date
2. Delete all entries prior an input date

Some might be recurring meetings

Right now, I'm doing Views and sorts and manually deleting such things


Thanks

Paul

Charlize
06-25-2008, 05:01 AM
Maybe this will help to get you started.Sub delete_meeting_before()
Dim mydate As Date
Dim mymeeting As Outlook.AppointmentItem
Dim myfolder As MAPIFolder
Dim myattstring As String
Dim vloop As Long
Set myfolder = Application.Session.GetDefaultFolder(olFolderCalendar)
mydate = DateSerial(2008, 1, 1)
For vloop = 1 To myfolder.Items.Count
Set mymeeting = myfolder.Items(vloop)
If mymeeting.Attachments.Count > 0 Then
myattstring = "Attachments : " & mymeeting.Attachments.Count
Else
myattstring = "No attachments found."
End If
If mymeeting.Start < mydate And mymeeting.End < mydate Then
MsgBox mymeeting.Subject & vbCrLf & mymeeting.Start & " - " & _
mymeeting.End & vbCrLf & myattstring, _
vbInformation, "To be deleted ..."
Else
MsgBox mymeeting.Subject & vbCrLf & mymeeting.Start & " - " & _
mymeeting.End & vbCrLf & myattstring, _
vbInformation, "NOT to be deleted ..."
End If
Next vloop
End SubCharlize