Outlook Solutions Archive

If you need to count the inbox emails by sender domain, it is too stupid to figure out the domain of each email and then count one by one. It is highly suggested to utilize the 2 methods introduced in this article.

Perhaps you have received a great number of emails in Inbox. Thereby, now, you want to count them. Maybe not only do you want to get a total count, but also you would like to count the inbox emails by sender domain. Here we will introduce 2 methods to quickly get the counts by sender domain.

Method 1: Get Count after Grouping Emails by Sender Domain

  1. For a start, trigger VBA editor according to “How to Run VBA Code in Your Outlook“.
  2. Then, put the VBA code below into a module.
Sub GetSenderDomain()
    Dim objInboxItems As Outlook.Items
    Dim i As Long
    Dim objMail As Outlook.MailItem
    Dim objDomainProperty As Outlook.UserProperty
    Dim strSenderAddress, strSenderDomain As String
 
    Set objInboxItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
 
    For i = objInboxItems.Count To 1 Step -1
        If TypeOf objInboxItems(i) Is MailItem Then
           Set objMail = objInboxItems(i)
 
           Set objDomainProperty = objMail.UserProperties.Find("Domain", True)
           If objDomainProperty Is Nothing Then
              Set objDomainProperty = objMail.UserProperties.Add("Domain", olText, True)
           End If
 
           strSenderAddress = objMail.SenderEmailAddress
           strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
 
           objDomainProperty.Value = strSenderDomain
           objMail.Save
        End If
    Next
End Sub

VBA Code - Get Sender Domain

  1. Next, open Inbox and go to “View” tab and click “View Settings”.
  2. In popup dialog, click “Group By”.
  3. Then, in the subsequent dialog box, uncheck “Automatically group according to arrangement”.
  4. After that, choose “User-defined fields in Inbox” from the dropdown list of “Select available fields from”.
  5. Later, select “Domain” in “Group items by”.Group Inbox Emails by Sender Domain
  6. Lastly, click a series of “OK” to save the changed view settings.
  7. Now, in Inbox, when hovering cursor above a group header, you can see the email count of the specific sender domain, like the following figure.Get Count in Email Group Header

Method 2: Count by Sender Domain Directly via VBA

  1. To begin with, in Outlook VBA editor, copy the following code into a module.
Sub CountInboxEmailsbySenderDomain()
    Dim objDictionary As Object
    Dim objInbox As Outlook.Folder
    Dim i As Long
    Dim objMail As Outlook.MailItem
    Dim strSenderAddress As String
    Dim strSenderDomain As String
    Dim varSenderDomains As Variant
    Dim varItemCounts As Variant
    Dim strMsg As String
 
    Set objDictionary = CreateObject("Scripting.Dictionary")
    Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
 
    For i = objInbox.Items.Count To 1 Step -1
        If objInbox.Items(i).Class = olMail Then
           Set objMail = objInbox.Items(i)
 
           strSenderAddress = objMail.SenderEmailAddress
           strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
 
           If objDictionary.Exists(strSenderDomain) Then
              objDictionary(strSenderDomain) = objDictionary(strSenderDomain) + 1
           Else
              objDictionary.Add strSenderDomain, 1
           End If
        End If
    Next
 
    varSenderDomains = objDictionary.Keys
    varItemCounts = objDictionary.Items
 
    For i = LBound(varSenderDomains) To UBound(varSenderDomains)
        strMsg = varSenderDomains(i) & vbTab & varItemCounts(i) & vbCrLf & strMsg
    Next
 
    MsgBox "Inbox Email Count by Sender Domain: " & vbCrLf & vbCrLf & strMsg, vbInformation + vbOKOnly
End Sub

VBA Code - Count Inbox Emails by Sender Domain

  1. Eventually, press “F5” key button.
  2. At once, you’ll receive the message prompting of the email counts by sender domain, as shown in the screenshot below.Message Prompting Email Counts

Escape from PST Data Loss

Since Outlook PST file contains all the items in your Outlook, you definitely don’t want to lose it. Hence, you have to firstly back up the file at regular intervals. Also, you should know how to find and launch Scanpst to repair Outlook file. Of course, since the inbuilt tool is unable to make effects in many cases, you had better get hold of a powerful external 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 mdf recovery and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment

This post will teach you a method to quickly find all rules which configure Outlook to auto forward emails to a specific person.

If you’ve created a great amount of rules in Outlook and now need to make some modifications on specific rules, such as the rules that auto forward emails to a specific person, since Outlook doesn’t provide features to search rules, you have to manually find the specific rules. It can be considerably troublesome in face of multiple rules. Therefore, here we’ll teach  a quick means to find all the rules that auto forward emails to a specific person.

Quickly Find All Rules that Auto Forward Emails to a Specific Person

  1. At the outset, launch Outlook application.
  2. Then, get access to VBA editor according to “How to Run VBA Code in Your Outlook“.
  3. Next, put the following code into an unused module.
Sub FindAllRules_AutoForwardEmailsToSpecificPerson()
    Dim strFind As String
    Dim objRules As Outlook.Rules
    Dim i As Long
    Dim objRule As Outlook.Rule
    Dim objRuleAction As Outlook.RuleAction
    Dim objForwardAction As Outlook.SendRuleAction
    Dim objFWActionRecipients As Outlook.Recipients
    Dim objFWActionRecipient As Outlook.Recipient
    Dim strFWRecipients As String
 
    'Enter the email address of the specific person
    strFind = InputBox("Specify the email address:", "Find", "johnsmith@datanumen.com")
 
    If strFind <> "" Then
       Set objRules = Outlook.Application.Session.DefaultStore.GetRules
 
       For i = objRules.Count To 1 Step -1
           Set objRule = objRules(i)
 
           strFWRecipients = ""
           For Each objRuleAction In objRule.Actions
               If (objRuleAction.ActionType = olRuleActionForward) Or (objRuleAction.ActionType = olRuleActionForwardAsAttachment) Then
 
                  Set objForwardAction = objRuleAction
                  Set objFWActionRecipients = objForwardAction.Recipients
 
                  For Each objFWActionRecipient In objFWActionRecipients
                      strFWRecipients = objFWActionRecipient.Name & " - " & objFWActionRecipient.Address & " ; " & strFWRecipients
                  Next
               End If
           Next
 
           If InStr(strFWRecipients, strFind) > 0 Then
              objRule.Enabled = True
              objRules.Save
           ElseIf strFWRecipients = "" Then
              objRule.Enabled = False
              objRules.Save
           End If
       Next
    End If
End Sub

VBA Code - Quickly Find All Rules that Auto Forward Emails to a Specific Person

  1. After that, run this macro via either pressing “F5” key or clicking the “Run” in toolbar.
  2. Then, you need enter the specific person’s email address in the small dialog box.Specify Person
  3. Finally, after the macro finishes, you can go to “File” menu and click “Manage Rules & Alerts” button.
  4. In the new “Rules and Alerts” window, as you can see, only the rules, which auto forward mails to the specific person, are enabled with a tick. And the other rules are disabled, like the following screenshot.Only Specific Rules Are Enabled

When Outlook Data Is Virus-infected

Similar to other ordinary files, Outlook PST file can be attacked by viruses and malware easily. It is because that email borne viruses are considerably common. For instance, once you download any malicious email attachments, your Outlook file can be corrupted. At that point, you have no choice but to take aid of a potent PST repair 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 repair mdf and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment

By default, you cannot let Outlook auto use different font colors for replying and forwarding emails. Therefore, if you have such a requirement, you can read this post to learn a smart approach.

Outlook only permits you to specify a font used for both replying and forwarding emails. You can go to “File” > “Options”. Then, in “Outlook Options”, turn to “Mail” tab and click “Stationery and Fonts…” button. In the subsequent window, you can see the “Font” button in “Replying or forwarding messages”. Click it, and then you can set a specific font color for replying and forwarding emails.

Change font in replying or forwarding messages

However, many users hope to use different font colors for replying or forwarding emails. Though Outlook doesn’t provide any direct features for this, it still can be realized with VBA code. Now, read on to get such a piece of VBA code.

Auto Use Different Font Colors for Replying and Forwarding Emails

  1. For a start, launch Outlook application.
  2. Then, trigger the VBA editor with reference to “How to Run VBA Code in Your Outlook“.
  3. Next, in accordance to “How to Add an Object Library Reference in VBA“, add the reference to “MS Word Object Library”.
  4. Subsequently, copy the following code into “ThisOutlookSession” project.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objExplorer As Outlook.Explorer
Public WithEvents objMail As Outlook.MailItem

Private Sub Application_Startup()
    Set objInspectors = Outlook.Application.Inspectors
    Set objExplorer = Outlook.Application.ActiveExplorer
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If TypeOf Inspector.CurrentItem Is MailItem Then
       Set objMail = Inspector.CurrentItem
    End If
End Sub

Private Sub objExplorer_SelectionChange()
    On Error Resume Next
    If TypeOf objExplorer.Selection.Item(1) Is MailItem Then
       Set objMail = objExplorer.Selection.Item(1)
    End If
End Sub

Private Sub objMail_Reply(ByVal Response As Object, Cancel As Boolean)
    Dim objReply As Outlook.MailItem
    Dim objReplyDoc As Word.Document
    Dim objDocSelection As Word.Selection
 
    Cancel = True
    Set objReply = objMail.Reply
    objReply.Display
    Set objReplyDoc = objReply.GetInspector.WordEditor
    objReplyDoc.Range(0, 0).Select
    Set objDocSelection = objReplyDoc.Application.Selection
    'Use "Pink" font in "Reply"
    objDocSelection.Font.ColorIndex = wdPink
End Sub

Private Sub objMail_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    Dim objReplyAll As Outlook.MailItem
    Dim objReplyAllDoc As Word.Document
    Dim objDocSelection As Word.Selection
 
    Cancel = True
    Set objReplyAll = objMail.ReplyAll
    objReplyAll.Display
    Set objReplyAllDoc = objReplyAll.GetInspector.WordEditor
    objReplyAllDoc.Range(0, 0).Select
    Set objDocSelection = objReplyAllDoc.Application.Selection
    'Use "Green" font in "Reply All"
    objDocSelection.Font.ColorIndex = wdGreen
End Sub

Private Sub objMail_Forward(ByVal Forward As Object, Cancel As Boolean)
    Dim objForward As Outlook.MailItem
    Dim objForwardDoc As Word.Document
    Dim objDocSelection As Word.Selection
 
    Cancel = True
    Set objForward = objMail.Forward
    objForward.Display
    Set objForwardDoc = objForward.GetInspector.WordEditor
    objForwardDoc.Range(0, 0).Select
    Set objDocSelection = objForwardDoc.Application.Selection
    'Use "Blue" font in Forward
    objDocSelection.Font.ColorIndex = wdBlue
End Sub

VBA Code - Auto Use Different Font Colors for Replying and Forwarding Emails

  1. After that, restart Outlook to activate this macro.
  2. Finally, you can have a try.
  • Select or open an email.
  • Then, click “Reply” button. In replying email, you can type some words in body. The font color must be pink."Pink" Font in "Reply"
  • Or click “Reply All” button. In the new “replying all” mail, input words in body. The font color is surely green."Green" Font in "Reply All"
  • Similarly, click “Forward” button. In the forwarding mail, the new words will be shown in blue."Blue" Font in "Forward"

Take Recourse to Reliable Software

In the event of Outlook corruption, most users tend to resort to Outlook recovery software. There are a great amount of such programs available in market. And some of them are even free of charge. Nevertheless, you ought to beware of those from unknown sources in that they may make the current case worse and worse. You ought to take aid of a reliable and experienced 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 corrupted sql and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment