How to Quickly Get the Total Count of the Emails from a Specific Sender in Outlook

Sometimes, you may want to count the total number of the emails from a specific sender in Outlook. This article will introduce you a handy way to quickly get the total count with Outlook VBA.

For some reasons, such as data statistics, you may be required to count the total number of the emails from a specific sender. Without any doubts, if you have numerous mails, manually counting them one by one will be rather troublesome and prone to error. In this case, why not recur to VBA? Here are the detailed operations and according VBA codes.

Get the Total Count of Emails from a Specific Sender in a Certain Folder

  1. At the very outset, start Outlook and shift to “Developer” tab.
  2. Then click on the “Visual Basic” button under this tab.Visual Basic under Developer Tab
  3. Next in the popup “Microsoft Visual Basic for Applications” window, you can open a module that is not in use and then copy the following VBA codes into it.
Sub CountEmailsfromSpecificSenderinCurrentFolder()
    Dim objSelection As Selection
    Dim objSelectedMail As MailItem
    Dim strSenderEmailAddress As String
    Dim objCurrentFolder As Folder
    Dim objItem As Object
    Dim objVariant As Variant
    Dim i As Long
    Dim strPrompt As String
    Dim nResponse As Integer
 
    Set objSelection = Outlook.Application.ActiveExplorer.Selection
 
    i = 0

    If TypeOf objSelection.Item(1) Is MailItem Then
 
       Set objSelectedMail = objSelection.Item(1)
       strSenderEmailAddress = objSelectedMail.SenderEmailAddress
       Set objCurrentFolder = Outlook.Application.ActiveExplorer.CurrentFolder
 
       For Each objItem In objCurrentFolder.Items
           Set objVariant = objItem
           If (objVariant.Class = olMail) And (objVariant.SenderEmailAddress = strSenderEmailAddress) Then
              i = i + 1
           End If
       Next
    End If
 
    strPrompt = "There are " & i & " emails from " & objSelectedMail.SenderName & " in the current " & objCurrentFolder.Name & " folder."
    nResponse = MsgBox(strPrompt, vbOKOnly + vbInformation, "Count Emails from Specific Sender")
End Sub

VBA Codes - Quickly Get the Number of the Emails from a Specific Sender in a Certain Outlook Mail Folder

  1. Subsequently, close the current window to return to Outlook main screen.
  2. After that, you can proceed to add the new macro to Quick Access Toolbar.
  • Firstly, click on the down arrow in Quick Access Toolbar and select “More Commands”.
  • And then add the macro to Quick Access Toolbar by following the steps in sequence shown in the following image.Add the New Macro to Quick Access Toolbar
  1. Finally you can try this button.
  • First, open a certain folder and select an email from the specific sender.
  • Then click the button in Quick Access Toolbar.
  • Lastly, you will receive a message, which is telling you the number of the emails from the specific sender in the current folder.Get the Total Count of Emails from a Specific Sender in a Certain Mail Folder

Traverse All the Subfolders Recursively

The above part just introduces you how to get the total count of all the mail items from a specific sender in one mail folder. If you have many subfolders under Inbox and you want to also include the received emails in the subfolders, you will need to enumerate all these subfolders recursively. In this case, you can refer to another article in our blog – “How to Traverse a Folder Tree Recursively in Outlook via VBA”.

Never Trust in Unreliable Outlook Repair Tool

Due to the fact that Outlook is error prone, so many users get used to keeping an Outlook error repair tool handy. But in today’s market, there are too many such unreliable tools. So you should keep cautious when selecting one. Once you try to fix the errors via an undependable tool, there are great chances that it will lead to worse situations.

Author Introduction:

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

One response to “How to Quickly Get the Total Count of the Emails from a Specific Sender in Outlook”

Leave a Reply

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