How to Auto Color Categorize Contacts Based on Their Countries in Your Outlook

How do you categorize your Outlook contacts? If you always assign color categories to your contacts as per their countries, why don’t you let your Outlook auto do this? This post will teach you to get it with VBA.

Many users prefer “Color Categories” feature in Outlook. It can help users classify and manage their Outlook items in a better and ordered way. Yet, with increasing items created, it is a bit tedious to manually assign color categories. And at times, you may forget assigning categories. In this case, you must wish Outlook to auto color categorize items as per your desired criteria. For instance, if you are used to color categorizing your contacts as per country, you can use the following way to realize it.

Auto Color Categorize Contacts Based on Their Countries

Auto Color Categorize Contacts Based on Their Countries

  1. For a start, hit “Alt + F11” key buttons to access VBA editor.
  2. Then, in the “Microsoft Visual Basic for Applications” window, copy the VBA code below into the “ThisOutlookSession” project.
Public WithEvents objContacts As Outlook.Items

Public Sub Application_Startup()
    'Get the default Contact folder's items
    Set objContacts = Application.Session.GetDefaultFolder(olFolderContacts).Items
End Sub

'Occurs when new contact is added to the specified Contact folder
Public Sub objContacts_ItemAdd(ByVal Item As Object)
    If TypeOf Item Is ContactItem Then
       Call AutoColorCategorize(Item)
    End If
End Sub

Public Sub AutoColorCategorize(ByVal objContact As Outlook.ContactItem)
    Dim strCategories As String
    Dim strBusinessCountry, strHomeCountry, strOtherCountry As String
 
    strCategories = objContact.Categories
 
    strBusinessCountry = objContact.BusinessAddressCountry
    strHomeCountry = objContact.HomeAddressCountry
    strOtherCountry = objContact.OtherAddressCountry
 
    'Auto categorize the new contact based on address country
    If strBusinessCountry <> "" Then
       objContact.Categories = strCategories & ";" & strBusinessCountry
    ElseIf strHomeCountry <> "" Then
       objContact.Categories = strCategories & ";" & strHomeCountry
    ElseIf strOtherCountry <> "" Then
       objContact.Categories = strCategories & ";" & strOtherCountry
    End If
    objContact.Save
End Sub

VBA Code - Auto Color Categorize Contacts Based on Their Countries

  1. After that, exit the VBA editor.
  2. Lastly, restart your Outlook to activate the new macro.
  3. From now on, every time when a new contact is created in the folder, Outlook will auto assign the corresponding color category to this contact according to the contact’s address country.Categorize Contacts by Country

If Inbuilt Tool Doesn’t Help Matters

Are you a regular user of Outlook? If you are, have you encountered any serious Outlook problems before? It is believed that you may have ever suffered errors or even Outlook PST file damage. Fortunately, under such circumstance, you can use the inbox repair tool to attempt Outlook fix. Nevertheless, as a matter of fact, this built-in utility will not be helpful all the time. Therefore, assuming that it cannot help you, you have no choice but to resort to a more experienced and reliable 3rd party tool, such as 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 sql fix and outlook repair software products. For more information visit www.datanumen.com