How to Auto Categorize the New Incoming Emails Based on the Senders’ Contact Categories

Some Outlook users prefer to categorize their emails as per the senders’ contact color categories. Manually assigning the category must be cumbersome. This article will introduce how to realize it automatically with Outlook VBA.

So as to improve your work efficiency in Outlook, you will make efforts to better manage your emails. Without any doubts, “Color Categories” is a good feature in this respect. Many users prefer to utilize it to organize and distinguish their mails. Of course, the concrete basis of color categorizing emails is up to your personal habits. For instance, some users have color categorized their contacts, therefore, they hope to categorize their emails according to the senders’ contact categories. If you do this manually, it will be definitely messy in that you have to firstly check the sender’s contact categories and then manually assign it to the email.

To tackle this requirement, actually you can make use of Outlook VBA, which can let Outlook auto check the sender’s contact categories and assign it to the new emails. If you are interested in this feature, read on to get the elaborate steps and codes.

Auto Categorize the Incoming Emails by the Senders’ Contact Categories

  1. In the first place, launch Outlook and press “Alt + F11” key buttons.
  2. Then the VBA editor window will show up, in which you need to find and open the “ThisOutlookSession” project.
  3. Next copy and paste the following VBA codes into “ThisOutlookSession”.
Public WithEvents olItems As Outlook.Items

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

Private Sub olItems_ItemAdd(ByVal Item As Object)
    Dim oMail As MailItem
    Dim olContacts As Outlook.Items
    Dim obj As Object
    Dim objVariant As Variant
    Dim olCategory As String
    Set olContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items
    If TypeOf Item Is MailItem Then
       Set oMail = Item
       For Each obj In olContacts
           If TypeOf obj Is ContactItem Then
              Set objVariant = obj
              If objVariant.Email1Address = oMail.SenderEmailAddress Then
                 olCategory = objVariant.Categories
                 oMail.Categories = olCategory
              End If
           End If
    End If
End Sub

VBA Codes - Auto Categorize the New Incoming Emails Based on the Senders’ Contact Categories

  1. Subsequently, you should assign a digital certificate to the new macro.
  • Firstly, create a new certificate via Digital Certificates for VBA Projects.
  • Then digitally sign this code.Digitally Sign the New Macro
  1. After that, you can change your Outlook macro security, only permitting the digitally signed macros.Change Your Macro Security Settings
  2. Finally you can restart Outlook to activate the new macro. From now on, all the incoming emails that arrive in Inbox folder will be auto categorized by the senders’ contact categories.Email Has the Same Category as Its Sender Contact

Settle Unexpected Outlook Crash

Although Outlook is preferred by many users, it still can’t get rid of crash. You must feel panic when suffering unanticipated Outlook crash. Do not worry. You can take actions to diagnose and solve the issues on your own, such as restarting Outlook, disabling third party add-ins, creating a new mail profile, and repairing Office suite and so on. The worst case must be corrupt Outlook PST data, which is extremely knotty. In this scenario, you need recur to a robust external tool, like DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair corrupt SQL mdf db and outlook repair software products. For more information visit

One response to “How to Auto Categorize the New Incoming Emails Based on the Senders’ Contact Categories”

Leave a Reply

Your email address will not be published. Required fields are marked *