title says it all
From stackoverflow
-
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.
-
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
0 comments:
Post a Comment