Process messages received on a day of the week

Last reviewed on December 3, 2012

Run a script rule

To use the code, you'll create a rule with the desired conditions and choose 'run a script' as the only action, selecting this script.


Sub KeepFriday(Item As Outlook.MailItem)
datefri = WeekdayName(Weekday(aItem.ReceivedTime))

If datefri = "Friday" Then

'moves to the Friday subfolder under Inbox. 
   Item.Move Session.GetDefaultFolder(olFolderInbox).Folders("Friday")
Else 
   Item.Delete
End If


End Sub

VBA to run anytime

To use this code sample select the folder then run the macro


Sub KeepFridayOnly()
Dim myolApp As Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim dest As Outlook.MAPIFolder

Dim aItem As Object
Dim datefri As String

Set myolApp = CreateObject("Outlook.Application")
Set mail = myolApp.ActiveExplorer.CurrentFolder

For Each aItem In mail.Items

datefri = WeekdayName(Weekday(aItem.ReceivedTime))

If datefri = "Friday" Then
   aItem.Move Session.GetDefaultFolder(olFolderInbox).Folders("Friday")
End If

Next aItem

 Set aItem = Nothing
 Set myolApp = Nothing
 
End Sub


Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999 and involved in IT support since 1985, Diane is the author of several books and video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.