5 pts.
 MailBox Rule Deletes
How do I sent up a mailbox rule that will automatically delete mail if older then one month

Software/Hardware used:
ASKED: May 13, 2008  3:03 PM
UPDATED: May 14, 2008  2:28 PM

Answer Wiki:
Hello, you can create a VBA script that handles this. In Outlook press ALT+F11 and write your code as in the following example: <pre> Sub CustomMailMessageRule(Item As Outlook.MailItem) ' Must always be named as follows otherwise ' you cannot use it as an Outlook rule DeleteOlder End Sub Sub DeleteOlder() On Error GoTo DeleteOlder_err Dim ns As NameSpace Dim Inbox As MAPIFolder Dim Item As Object Dim Atmt As Attachment Dim FileName As String Dim i As Integer Dim SentDate As Date Set ns = GetNamespace("MAPI") Set Inbox = ns.GetDefaultFolder(olFolderInbox) For Each Item In Inbox.Items ' Work with the date difference of the "Item.SentOn" data and you have what you need If DateDiff("d",Item.SentOn,Now) > 30 Then .... End if Next Item DeleteOlder_exit: Set Atmt = Nothing Set Item = Nothing Set ns = Nothing Exit Sub DeleteOlder: Resume DeleteOlder_exit End Sub </pre> Once you've tested this you can simply create an Outlook rule that will be run according to your needs, I hope this helps. Regards, Alessandro
Last Wiki Answer Submitted:  May 14, 2008  2:28 pm  by  alessandro.panzetta   9,695 pts.
All Answer Wiki Contributors:  alessandro.panzetta   9,695 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _