title says it all
views:
12answers:
2
A:
Find a folder: http://stackoverflow.com/questions/635558/accessing-another-maibox-in-outlook-using-vba/638173#638173
Delete items: http://stackoverflow.com/questions/1782498/outlook-macro-why-doesnt-this-delete-all-items-from-deleted-folder/1783634#1783634
I am fairly sure there are more.
Remou
2010-05-26 20:05:10
+1
A:
Here is a example script
Sub DeleteOlderThan6months()
Dim oFolder As Folder
Dim Date6months As Date
Dim ItemsOverMonths As Outlook.Items
Dim DateToCheck As String
Date6months = DateAdd("d", -182, Now())
Date6months = Format(Date6months, "mm/dd/yyyy")
Set oFolder = Application.Session.PickFolder 'or set your folder
DateToCheck = "[Received] <= """ & Date6months & """"
Set ItemsOverMonths = oFolder.Items.Restrict(DateToCheck)
For i = ItemsOverMonths.Count To 1 Step -1
ItemsOverMonths.Item(i).Delete
Next
Set ItemsOverMonths = Nothing
Set oFolder = Nothing
End Sub
76mel
2010-05-26 23:42:28