Move messages CC'd to an address

Last reviewed on September 23, 2013   —  3 comments

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

About Diane Poremsky

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.

Please post long or more complicated questions at Outlook forums by

3 responses to “Move messages CC'd to an address”

  1. cmsgraham

    In my case the first script is working when the dl or alias name is the only mail in the cc. If there are more addresses in the cc does not works. Tks

    1. Diane Poremsky

      Use something like this instead:
      If InStr(LCase(objMail.CC), "address") Then

  2. Stephen

    Thank you so much for your quick response! I got it moving to the correct folder now but seems to be moving a lot others as well but will try and work that out...

    Thank you again!


Leave a Reply

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

This site uses XenWord.