Okay, I just wrote my first Outlook macro - so don't blame me if it deletes all your mails. Backup before you try! :)
In Outlook go to Tools > Macros > Macro. Enter the name you want to give the macro. I named mine "Delete_Old_Notifications".
Here's the macro code I wrote:
Sub Delete_Old_Notification()
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
Dim inbox As Outlook.MAPIFolder
Set inbox = ns.GetDefaultFolder(olFolderInbox)
Dim item As Object 'Outlook.MailItem
Dim Action As Integer
Dim Categories, Category
Action = 0
For Each item In inbox.Items
If Len(item.Categories & "") > 0 Then
Categories = Split(item.Categories, ";")
For Each Category In Categories
Select Case LCase(Trim(Category))
Case "notification":
If DateDiff("d", item.ReceivedTime, Now) > 14 Then
Action = 1
End If
End Select
Next
End If
Select Case Action
Case 1: MsgBox ("Delete '" & item.Subject & "'") 'item.Delete
End Select
Action = 0
Next
End Sub
(Could be shorter, yes - but I built it to be extensible.)
Notes:
- It looks in the standard inbox. If you want another folder, you have to modify the "Set inbox" folder. To look in subfolders of the inbox, add .Folders("foldername") at the end of the line
- Currently it checks if the mail has a category "notification". If you want another category, insert that in the Case. Just make it lower case because I convert them all to lower case - just to be sure.
- Currently it affects mails with an age of 14 days or above. See that in the If DateDiff line.
Currently it does not actually delete, it just shows a notification. To make it actually work you need to remove the MsgBox near the bottom of the Sub and keep the line like this:
Case 1: item.Delete
You might want to look at these two forum posts to find out...