Move messages CC'd to an address

Last reviewed on September 23, 2013

When you create a rule in Outlook, you can look for messages sent To or CC'd to an address but you can't look only at the CC field. If you want to create a rule to act on mail only by an address in the CC field, you need to use VBA.

The scripts on this page moves messages CC'd to an Exchange DL to a subfolder of the Inbox. Run a script rules (well, any rules) are fine for light-duty work, but when they need to process a lot of mail at once, some messages may be skipped. In those cases, using an ItemAdd event may be better, but even so, under really heavy loads, some messages may still be skipped.

Use a run a script rule to move mail cc'd to someoneThe first sample uses in a Run a Script rule. To use it, create a rule with the condition "Sent to people or group", entering the address you want to filter on. This rule will apply only to mail where the address in the To or CC field. The script will check the CC field for an address or alias and if found, do something. In this example, the message is moved to a subfolder of the Inbox.

The second sample does not use Rules Wizard, instead it runs when Outlook starts and moves mail meeting the condition. It checks every message to see if the CC matches the name you entered.

These rules can be edited to move messages based on other conditions.

Use a Run a Script rule

To use, create a rule with the run a script action, choosing this script.


Sub MoveMail(Item As Outlook.MailItem)
    Dim strID As String
    Dim objMail As Outlook.MailItem
    
    strID = Item.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)

   If objMail.CC = "dl or alias name" Then
      objMail.Move Session.GetDefaultFolder(olFolderInbox).Folders("subfolder-name")
   End If

Set objMail = Nothing

End Sub

Move the messages using an ItemAdd Event

To use this script, place it at the top of ThisOutlookSession and click in the Application_Startup macro then press Run to enable it without restarting Outlook.

Option Explicit

Private WithEvents olInboxItems As Items

Private Sub Application_Startup()
  Dim objNS As NameSpace
  Set objNS = Application.Session
  ' instantiate objects declared WithEvents
  Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
  Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
  On Error Resume Next
  Dim strID As String
    Dim objMail As Outlook.MailItem
    
    strID = Item.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)

   If objMail.CC = "alias" Then
      objMail.Move Session.GetDefaultFolder(olFolderInbox).Folders("folder-name")
   End If

Set objMail = Nothing

End Sub

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created 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.

If the Post Coment button disappears, press your Tab key.