How to Auto Move the Emails with Specific CC Recipients in Outlook

In reality, most of you may hope to create an Outlook rule to auto move the emails with specific CC recipients. But Outlook rule doesn’t support checking CC recipients. So this article will teach you how to realize it with Outlook VBA.

Obviously, it is impossible for you to create an Outlook rule to search specific CC recipients. As shown in the following screenshot, for received emails, you can only check if your own name is in the CC box. Similarly, for sent emails, even there is no rule condition to check CC box.No Conditions to Look for CC Recipient

Therefore, if you would like to configure Outlook to move the emails with specific CC recipients automatically, you have to seek other means. Then. here we will teach you how to achieve it by means of Outlook VBA.

Auto Move the Sent Emails with Specific CC Recipients

  1. Firstly, turn to “Developer” tab and click on “Visual Basic” button.
  2. Then open the “ThisOutlookSession” project and copy the following VBA codes into it.
Public WithEvents olItems As Outlook.Items

Sub Application_Startup()
    Set olItems = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Sub olItems_ItemAdd(ByVal Item As Object)
    If Item.Class = olMail Then
       MoveMail Item
    End If
End Sub

Sub MoveMail(Mail As Outlook.MailItem)
    Dim ccRecip As String
    Dim desFolder As Folder
 
    'Replace "test" with your desired CC'd recipient name or address
    ccRecip = "test"
    'The "Test" folder is a subfolder under "Sent Items" folder
    Set desFolder = Session.GetDefaultFolder(olFolderSentMail).Folders("Test")
 
    If InStr(LCase(Mail.CC), ccRecip) > 0 Then
       Mail.Move desFolder
    End If
End Sub

Auto Move the Sent Emails with Specific CC Recipients

  1. Subsequently, you should proceed to sign this code and change the macro settings as usual.
  2. Lastly, you can exit the “Visual Basic” window. Thereafter, the emails with the specific CC recipients will be moved to the specified mail folder.

Auto Move the Received Emails with Specific CC Recipients

Now that the above VBA code is aimed to move sent emails with specific CC recipients, If you want to look for specific CC recipients in received emails and then move it, you should use the following codes instead.

Public WithEvents olItems As Outlook.Items

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

Sub olItems_ItemAdd(ByVal Item As Object)
    If Item.Class = olMail Then
       MoveMail Item
    End If
End Sub

Sub MoveMail(Mail As Outlook.MailItem)
    Dim Recips As Recipients
    Dim Recip As Recipient
    Dim ccRecip As String
    Dim desFolder As Folder
 
    Set Recips = Mail.Recipients
    'Replace "test" with the specific words in your desired CC recipient address
    ccRecip = "test"
 
    For Each Recip In Recips
        If Recip.Type = olCC Then
           If InStr(LCase(Recip.Address), ccRecip) > 0 Then
              'The "Test" folder is a subfolder under "Inbox" folder
              Set desFolder = Session.GetDefaultFolder(olFolderInbox).Folders("Test")
              Mail.Move desFolder
           End If
        End If
    Next
End Sub

Auto Move the Received Emails with Specific CC Recipients

Keep Well-Prepared for Outlook Corruption

Though Outlook is feature rich, it still cannot be immune to corruption. So you should keep vigilant against all the potential risks. Undoubtedly, the critical step must be making a consistent and up-to-date backup for Outlook data. Furthermore, you should keep a corrupt Outlook recovery tool in vicinity. It will come in handy if both the backups and Scanpst.exe fail.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL Server mdf file error and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.