Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to sort and group by sender domain in Outlook?

Normally, we can easily arrange all email messages by sender, categories, subjects, size, etc. in Microsoft Outlook. However, it seems impossible to sort or group email messages by sender domains, because there is no Sender domain field for email messages at all. Here I will introduce a VBA code to help you add a Domain column for email messages, then sort and group the email messages by the sender domains easily in Outlook.

Office Tab - Enable Tabbed Editing and Browsing in Office, and Make Work Much Easier...
Kutools for Outlook - Brings 100 Powerful Advanced Features to Microsoft Outlook
  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by rules; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails at once; Auto Add Greeting when reply; Auto Add Date&Time into subject...
  • Attachment Tools: Auto Detach, Compress All, Rename All, Auto Save All... Quick Report, Count Selected Mails, Remove Duplicate Mails and Contacts...
  • More than 100 advanced features will solve most of your problems in Outlook 2010-2019 and 365. Full features 60-day free trial.

To sort and group email messages by sender domains in Microsoft Outlook 2013 and 2010, please do as following:

Step 1: Open the mail folder where you will sort all email messages by sender domains.

Step 2: Turn off the Reading Pane with clicking the Reading Pane > Off on the View tab.

Step 3: Go ahead and click the Add Columns on the View tab.

Step 3: In the Show Columns  dialog box, click the New Column button.

Step 4: In the New Column dialog box, type the Domain in the Name box, and keep the Text selected in the both Type box and Format box, at last click the OK button.

Step 5: Now you get back to the Show Columns dialog box, select the Domain in the Show these columns in this order box, move it below From item, and click the OK button.

Step 6: Now you go back to the opening mail folder, select all email messages with pressing the Ctrl + A keys at the same time.

Step 7: Press the Alt + F11 keys in a meanwhile to open the Microsoft Visual Basic for Applications window; then click the Insert > Module, next paste the following VBA code into the module.

VBA: Sort and Group by sender domain

Sub ListSelectionDomain()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim sDomain
On Error Resume Next
For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj
sDomain = Right(oMail.SenderEmailAddress, Len(oMail.SenderEmailAddress) - InStr(1, oMail.SenderEmailAddress, "@"))
Set oProp = oMail.UserProperties.Add("Domain", olText, True)
oProp.Value = sDomain
oMail.Save
Err.Clear
Next
End Sub

Step 8: Run this VBA code with pressing the F5 key or Run button in the Toolbar.

Step 9: Now each sender’s domain is extracted and filled into the Domain column.

A. To sort the email messages by sender domains, just click the Column header of Domain at the top of all email messages;

B. To group the email messages by sender domains, just right click the Column header of Domain, and select the Group By This Field from the drop down list. See screen shot below:

Notes:

(1) This VBA code works well in Outlook 2013 and 2010, but doesn’t work in Outlook 2007.
(2) You can save the custom view easily with How to save and copy view settings to other folders in Outlook?


arrow blue right bubbleRelated Article

How to view senders’ domain in mail list in Outlook?


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Rajiv · 1 years ago
    Thanks a lot for this article. It took ages to populate the Domain field values for around 10000 mails, in Outlook 2013. The sadder thing is that it does not sort the mails on the Domain field, either descending or ascending. I don't know what is wrong, some update in Outlook disables this, or because the number of mails are huge. The Domain values are displayed, but not sortable or groupable. Kindly help me fix this, thanks.
  • To post as a guest, your comment is unpublished.
    Cecilia Hayes · 1 years ago
    I'd like to do the same thing, but for the eMail Address. What values should be adjusted in the above code?
  • To post as a guest, your comment is unpublished.
    Alex · 2 years ago
    Getting an error in Outlook 365 (1705) "You cannot sort by this field."
  • To post as a guest, your comment is unpublished.
    Hakan · 2 years ago
    thanks for your effort, however, domain field does not behave like From field. When you group by domain and sort by another field, domain field disappears. any workarounds ?
  • To post as a guest, your comment is unpublished.
    Barbs · 3 years ago
    Hi,
    In the new Outlook 2016 when you sort inbox by sender it then creates headers. I absolutely hate it. How do i remove the useless headers? It never used to happen before.
    Thanks,
    Barbs
  • To post as a guest, your comment is unpublished.
    Justin · 4 years ago
    Thanks for this, just tried it out in Outlook 2016 and works a treat. Now the next thing which might not be possible but is there a way to then sort the group by domain messages based on the group by count rather than alphabetically based on the domain text?
    • To post as a guest, your comment is unpublished.
      Cal · 3 years ago
      [quote name="Justin"]Thanks for this, just tried it out in Outlook 2016 and works a treat. Now the next thing which might not be possible but is there a way to then sort the group by domain messages based on the group by count rather than alphabetically based on the domain text?[/quote]

      I can't find the option to add a column in Office 2016 for Mac - Office 365. Any idea? Thank you.
  • To post as a guest, your comment is unpublished.
    Richard Mountain · 4 years ago
    Works perfect!
    Many Thanks!