How to Auto Highlight All Incoming Emails from Unknown Domains in Outlook

So as to watch out for the emails from unknown domains, some users hope to let Outlook auto highlight them, such as show them in red color. Now, this article will introduce a method to realize it.

In order to block viruses in suspicious emails from attacking your Outlook data, you ought to pay special attention to those emails from unknown domains. Here, in the followings, we will share you a method to let Outlook auto highlight these emails with a manifest color.

Auto Highlight the Incoming Emails from Unknown Domains

  1. For a start, launch Outlook application.
  2. Then, trigger Outlook VBA editor according to “How to Run VBA Code in Your Outlook“.
  3. Next, copy the following VBA code into “ThisOutlookSession” project.
Public WithEvents objInbox As Outlook.Folder
Public WithEvents objInboxItems As Outlook.Items

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

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim objMail As Outlook.MailItem
    Dim objDomainProperty As Outlook.UserProperty
    Dim strSenderAddress, strSenderDomain As String

    If TypeOf Item Is MailItem Then
       Set objMail = Item
 
       Set objDomainProperty = objMail.UserProperties.Find("KnownDomain", True)
       If objDomainProperty Is Nothing Then
          Set objDomainProperty = objMail.UserProperties.Add("KnownDomain", olText, True)
       End If
 
       strSenderAddress = objMail.SenderEmailAddress
       strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
 
       'Change the specific domains
       If (strSenderDomain <> "datanumen.com") And (strSenderDomain <> "datanumen.net") Then
          objDomainProperty.Value = "No"
       Else
          objDomainProperty.Value = "Yes"
       End If
 
       objMail.Save
    End If
End Sub

VBA Code - Auto Highlight the Incoming Emails from Unknown Domains

  1. After that, click into “Application_Startup” subroutine and press “F5”.
  2. Subsequently, exit VBA editor and open the Inbox folder.
  3. Next, turn to “View” tab and click “View Settings”.
  4. In the popup dialog box, click “Conditional Formatting” button.
  5. Then, in the next new dialog box, click “Add” and specify a name.Add New Conditional Formatting Rule
  6. Afterwards, click “Font” and choose a highlighting color.Choose Highlight Color
  7. Later, click “Condition” tab.
  8. Next, switch to “Advanced” tab and add the criteria: “KnownDomain” > “s(exactly)” > “No”Add Rule Condition
  9. Finally, click several “OK” to save this conditional formatting rule.
  10. From now on, if a new email from the email address outside specific domains gets into Inbox, it will be highlighted in the specific color.Highlighted Emails from Unknown Domains

Keep Alert of All Harms to Outlook

There are lots of potential risks to your Outlook data file, including vulnerability, viruses, and human errors and so on. Therefore, you have to watch out for them all the time. For instance, you should never download suspicious attachments as well as keep exiting Outlook properly. Last but not least, it’s recommended to get hold of a robust and reliable PST repair tool, such as DataNumen Outlook Repair, which is able to restore damaged PST data with ease.

Author Introduction:

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

Comments are closed.