Automatic color category according to variable domains

Not open for further replies.


New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi All,

Sorry in advance if this question has been asked already, I just can't seem to find anything online that I can understand.

My experience with VBA is limited to its applications with excel.

Everyday, I receive hundreds of emails from variable external persons.
I would like to assigned these emails to a specific category.

I have made a test with one specific domain (see below my process) using "Rules and Alerts"
step 1: Select condition(s)
- with specific words in the sender's address
step 1: Select action(s)
- assign it to the category category
==> (red) "before to go"
Click "Finish"

My rule works well, however I have thousands of different senders and I want to automatize the process and keep the database for an easier update.
I extracted all of them on Excel and worked out my database, see below an example


Would it be possible to create a Macro linked to this "database"?
The macro would work as below
if specific words in the sender's address are into column B
If true, apply category color from column D to this email
Then do nothing.

I hope I gave you a clear explanation about my issue.
I maybe took the problem in the wrong way, if you have another solution, i'll be more than happy to take it :)

Thanks in advance for the help!

**Just a quick edit, I do not have a coding background at all and everything I know about excel has been learned through reading online guides extensively. I see a lot of code for Outlook and it is all foreign to me, if you could please explain what is happening in the code with comments that would be so greatly appreciated! Thanks again!


Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
you could do a lookup (i'd probably use CSV) but would only need the domain and the category name - the color comes from the category on the master category list. I don't think i have code that does it, but it wouldn't be hard to do.

I have a macro that looks up contacts and categorizes the email based on the category contact. That code is at Assign Categories to Messages using Contact Category

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I`d keep it all in Outlook. Group the view of the contacts folder by categories, then you can quickly assign the categories by dragging a contact into the appropraite group. If you press the ctrl button while dropping a contact, the new category will be added, otherwise it would replace all categories that were previously assigned to that contact.

This way you can use Diane´s macro without the need to change it. If your contacts have more categories assigned than you want to assign, you either need to adapt Diane´s macro, or use this Addin, which also looks up the contact and allows to determine categories that should never be assigned:
Category-Manager - VBOffice


New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Good afternoon Diane and Michael,

Sorry for the delay but I was trying to understand and to do it on my side follow your tips and Internet.

Indeed if I import all the contacts adding the category which has been set up, Diane's Macro works very well (many thanks for that Diane).
The issue is I have to update the list each time I receive an email from another user even if they have the same domain.

During the weekend I tried to understand how VBA for Outlook works.
To be honest, I didn't go far :-S, my understanding is still very limited.

I understand the function LookUp, but how to integrate it in Diane's Macro?

Many thanks for your help.

Kindest regards



New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi All,

I hope you are keeping well.

I have tried to create the wished macro follow internet instructions.

Unfortunately my Macro doesn't work (at all :-( )

Please find below the coding

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)

Dim sDomain As String
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim oSender

Set sDomain = Mid(oMsg.SenderEmailAddress, InStr(oMsg.SenderEmailAddress, "@") + 1)
'Set oSender = SenderAddress

'If Not oSender Is Nothing Then

Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("L:\..............\Supplierlisting.xlsx")
Set xlWS = xlWB.Worksheets(Category)

For Each c In xlWS.Range("E2:E15000")
Proj = c.Offset(0, 1).Value
Debug.Print c & Proj
Set sDomain = Nothing

If Not sDomain Is Nothing Then
Item.Categories = sDomain.Categories


Set Item = Nothing
End If
End If

'Set oSender = Nothing
Set sDomain = Nothing

End Sub

I really try to solve my problem by doing myself and making research. unfortunately without success.
Many thanks for your help

Warmest regards
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
B Removing Recipients from an automatic response Outlook VBA and Custom Forms 2
N automatic response with an attachment based on the subject line Outlook VBA and Custom Forms 1
E How to send automatic emails in outlook 2010 Using Outlook 1
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
M Outlook 2016 Desktop - Automatic Rule Processing Using Outlook 3
P Threat to being a spammer while sending automatic Emails through VBA Using Outlook 3
reza Macro to automatic reply using orignal mail Outlook VBA and Custom Forms 10
B Automatic picture download and changing email addresses Using Outlook 3
J why won't the automatic send/receive work Using Outlook 7
S rule, automatic replies, restricting them to within the company Using Outlook 1
I Automatic reply to an email Using Outlook 0
P Daily Automatic Reply Using Outlook 1
P Automatic reply on incoming messages in outlook using VBA(only Specifi person) Using Outlook 14
R automatic signature Using Outlook 0
B Looking for an add-in or a way to send automatic replies based off a list Using Outlook 2
H Automatic excel data added to Certain Emails that are received Using Outlook 3
M Automatic Bcc Using Outlook 2
C starting Outlook 2003 sp3 sets Junk Email setting to 'No automatic filtering' Using Outlook 3
K automatic cleanup folder Using Outlook 3
B How to automatic save Sending or replying contacts e-mails into contacts? Using Outlook 0
J Form design - how do I insert an automatic date/time field? Using Outlook 2
C Text reply mail in Outlook 2010 has automatic margin indent Using Outlook 9
T Automatic forwarding rule strips attachment Using Outlook 3
C How do I cancel automatic e-mail forwarding? Using Outlook 1
F Schedule an automatic send/receive every 1 minute Using Outlook 1
O I suddenly can't open Outlook after getting a microsoft automatic update. Using Outlook 2
M Outlook email not working since last automatic update. Using Outlook 2
A How do I stop automatic e-mail forwarding? Using Outlook 2
C Configuring automatic reply with an approved message attached to original received message that will be forward to a 3rd party Using Outlook 2
R Automatic Send/Receive when Opening 2010 Using Outlook 1
D Automatic back up of Outlook & BCM Using Outlook 3
D Automatic respond for sending mail problem Exchange Server Administration 4
C Email automatic paragraph and symbol formatting Using Outlook 1
R (GPO?) Setting that controls automatic picture download Outlook 2002 Using Outlook 3
M Download pictures automatic in incoming mails Using Outlook 1
R Disable automatic creation of outlook 2010 contacts for recipients Using Outlook 5
R outlook 2010 Automatic replies not opening Using Outlook 1
E Re: Disable automatic creation of outlook 2010 contacts for recipients Exchange Server Administration 2
H Outlook 2010 IMAP folders in Favorites and automatic mail check. Using Outlook 5
D Disable Automatic Folder Expansion Using Outlook 2
A Automatic print in outlook: Using rules and alerts Using Outlook 3
Z How to disable Automatic Wrap Text for sent email? Using Outlook 3
M Is it unsafe to block Automatic DB Activation with only 2 DAG members and 1 FSW??? Exchange Server Administration 8
R Setting up automatic meeting request acceptance Using Outlook 1
F Automatic formatting of single entries in Outlook calendar Using Outlook 1
J Automatic formatting a single instance of a recurring meeting Using Outlook 11
S how to set up automatic BCC to another email address? Using Outlook 1
C trying to set up automatic replies in microsoft outlook Using Outlook 2
M Exchange 2010 Services are not starting automatic on startup Exchange Server Administration 39
Similar threads