How to Quickly Create a Search Folder for a Specific Contact in Outlook

At times, you may wish to quickly create a search folder for a specific contact. Now, this article will introduce you an approach, which permits you to accomplish it just via one click.

Generally, to create a search folder for someone, you have to take several tedious steps, such as right clicking “Search Folder” in mail folder list, specifying the type of search folder, locating and selecting a contact in “Select Names” dialog box and so on. All in all, it may be a bit cumbersome. Therefore, in the followings, we’ll show you another way, which can realize it simply by one click.

Quickly Create a Search Folder for a Specific Contact in Outlook

Create a Search Folder for a Specific Contact

  1. At the very beginning, you should start your Outlook application as usual.
  2. Then, in the Outlook main screen, press the shortcut keys – “Alt + F11”.
  3. Next, you will get into VBA editor in success, where you need find and open the “ThisOutlookSession” project.
  4. Subsequently, you could copy and paste the following code into this project.
Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
    Dim objCommandBarButton As Office.CommandBarButton
    'Add "New Search Folder" to the ContactItem's Context Menu
    If (Selection.Count = 1) And (Selection.Item(1).Class = olContact) Then
       Set objCommandBarButton = CommandBar.Controls.Add(msoControlButton)
       With objCommandBarButton
           .Style = msoButtonIconAndCaption
           .Caption = "New Search Folder"
           .FaceId = 1744
           .OnAction = "Project1.ThisOutlookSession.CreateRelatedSearchFolder"
       End With
    End If
End Sub

Sub CreateRelatedSearchFolder()
    Dim objContact As Outlook.ContactItem
    Dim strEmailAddress As String
    Dim strDisplayName As String
    Dim strFilter As String
    Dim strFrom1, strFrom2, strTo1, strTo2 As String
    Dim strScope As String
    Dim objSearch As Outlook.Search
    'Get the selected contact
    Set objContact = Application.ActiveExplorer.Selection.Item(1)
    'Get the contact's main email address and display name
    strEmailAddress = objContact.Email1Address
    strDisplayName = objContact.Email1DisplayName
    If strEmailAddress = "" Then
       Exit Sub
    End If
    strFrom1 = ""
    strFrom2 = ""
    strTo1 = ""
    strTo2 = ""
    'Specify the search filter
    strFilter = "((""" & strFrom1 & """ CI_STARTSWITH '" & strEmailAddress & "' OR """ & strFrom2 & """ CI_STARTSWITH '" & strEmailAddress & "')" & " OR (""" & strTo1 & """CI_STARTSWITH '" & strEmailAddress & "' OR """ & strTo2 & """ CI_STARTSWITH '" & strEmailAddress & "' OR """ & strTo1 & """ CI_STARTSWITH '" & strDisplayName & "' OR """ & strTo2 & """ CI_STARTSWITH '" & strDisplayName & "' ))"
    'Specify the folders to be searched
    strScope = "'" & Application.Session.GetDefaultFolder(olFolderInbox).FolderPath & "','" & Application.Session.GetDefaultFolder(olFolderSentMail).FolderPath & "'"
    'Search all mails from or to the specific contact
    Set objSearch = Application.AdvancedSearch(strScope, strFilter, True, "SearchFolder")
    'Save the search results to a search folder
    objSearch.Save (objContact.FullName)
End Sub

VBA Code - Create a Search Folder for a Specific Contact

  1. After that, you should sign this code.
  2. Later, exit the current window and go to change your Outlook macro settings to enable the signed macros.
  3. Finally you can have a try.
  • Firstly, access the “Contacts” area and open a source Contacts folder.
  • Then you can select a contact and right click on it.
  • From the drop down list, you can find a “New Search Folder” option. Hit this option.Select "New Search Folder" Option from Context Menu
  • At once, a new search folder for the selected contact will be created. You can find it in the mail folder list, like the screenshot below:Search Folder for a Specific Contact

Cope with Occasional Outlook Errors

If you’ve used Outlook for decades, you must have suffered a lot of Outlook errors. Fortunately, tiny issues can be fixed by its inbuilt repair utility. However, at times it will not help matters in that the problems have highly exceeded what it can do. At this time, you have to recur to a more cogent and reliable tool, say DataNumen Outlook Repair. It can repair Outlook troubles in an instant and without any fuss.

Author Introduction:

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

Comments are closed.