Is it possible to set up rule in Outlook 2010 based on message class?

I recieve all the undeliverable reports for mailings sent from my company. Moving and cataloguing them can take a while, and it would be handy if I could create a rule that did that for me.

The most robust way of doing this would seem to be to run a rule based on the Undeliverable message class. However, I can't see message class as an option anywhere in the advanced rules wizard, and Googling it is no help.

EDIT: I already have a rule that searches for "Undeliverable" in the subject header of emails received and moves them, but this only affects traditional emails (i.e. those with a message class of "Message") and ignores actual undeliverable reports.

Am I missing something obvious, or can this not be done?


You can't do that with Outlook rules. But you can with Outlook macros. First, enable macros in Outlook Options' Trust Center. Then in Outlook press ALT+F11 to open VBA and paste the following macro to ThisOutlookSession. After that, save changes and restart Outlook. The macro will move all NDRs to "NDR" subfolder of your Inbox. It will also create this subfolder if necessary. Fell free to replace ("NDR") with your own folder name if needed.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
    Set Items = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
    On Error Resume Next

    If UCase(Item.MessageClass) = "REPORT.IPM.NOTE.NDR" Then
        Set Folders = Session.GetDefaultFolder(olFolderInbox).Folders
        Set Folder = Folders.Item("NDR")
        If Folder Is Nothing Then
            Folder = Folders.Add("NDR")
        End If
        Item.Move Folder
    End If
End Sub