StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Privacy Policy
E-Mail: Find address in CC and move the item
Author: Michael BauerHomepage
Date: 23.11.2009Accessed: 14856

With rules you can only look for your own address in the cc field in order to move the email.

With this example you can look for any string in CC. If it's found, the email will be moved into a subfolder of the inbox

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace

  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is Outlook.MailItem Then
    MoveMessage Item
  End If
End Sub

Private Sub MoveMessage(Item As Outlook.MailItem)
  Dim Ns As Outlook.NameSpace
  Dim Recipients As Outlook.Recipients
  Dim Recip As Outlook.Recipient
  Dim Folder As Outlook.MAPIFolder
  Dim Find As String

  Find = "info"

  Set Recipients = Item.Recipients
  For Each Recip In Recipients
    If Recip.Type = olCC Then
      If InStr(1, Recip.Address, Find, vbTextCompare) Then
        Set Ns = Application.GetNamespace("MAPI")
        Set Folder = Ns.GetDefaultFolder(olFolderInbox)
        Set Folder = Folder.Folders("example")
        Item.Move Folder
        Exit For
      End If
    End If
End Sub

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]


Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]


SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]


OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]