How to Quickly Create a Search Folder for All Unreplied Emails via Outlook VBA

In order to check the unreplied emails more easily in your Outlook, you can create a search folder for such emails. Now, this article will introduce you how to get it with Outlook VBA.

In the previous article “How to Auto Highlight the Important Emails You Haven’t Replied in Outlook”, you can learn a means to show the vital emails you haven’t replied in a specific color. But, you may feel it still troublesome in that you have to look through all mail folders one by one. Hence, you would like to directly collect all such emails in a search folder. Now, in the followings, we will teach you to use VBA to quickly create such a search folder.

Create a Search Folder for All Unreplied Emails

  1. At the very outset, start Outlook application.
  2. Then, press “Alt + F11” keys to access VBA editor.
  3. Next, copy the following VBA code into a module that is not in use.
Sub CreateSearchFolder_AllNotRepliedEmails()
    Dim strScope As String
    Dim strRepliedProperty As String
    Dim strFilter As String
    Dim objSearch As Outlook.Search
 
    'Specify the folders to be searched
    'Here we use Inbox folder for an example
    strScope = "'" & Application.Session.GetDefaultFolder(olFolderInbox).FolderPath & "'"
 
    'Search filter
    strRepliedProperty = "http://schemas.microsoft.com/mapi/proptag/0x10810003"
    strFilter = Chr(34) & strRepliedProperty & Chr(34) & " <> 102" & "AND" & Chr(34) & strRepliedProperty & Chr(34) & " <> 103"
    Set objSearch = Outlook.Application.AdvancedSearch(Scope:=strScope, Filter:=strFilter, SearchSubFolders:=True, Tag:="SearchFolder")
 
    'Save the search folder
    objSearch.Save ("Not Replied Emails")
    MsgBox "Search folder is created successfully!", vbInformation + vbOKOnly, "Search Folder"
End Sub

VBA Code - Create a Search Folder for All Unreplied Emails

  1. Subsequently, put cursor in this subroutine.
  2. After that, click “F5” key button to trigger this macro.
  3. When macro finishes, a message, like the following figure, will display.Prompt about "Complete"
  4. Finally, you can see a new search folder called “Not Replied Emails”, which contains all the unreplied emails in Inbox.New Search Folder for Unreplied Emails

Change Search Scope of the Search Folder

In my VBA code, this search folder only searches the default Inbox folder. If you want to change the search scope, you can follow the steps below.

  1. First off, right click the search folder.
  2. Then, choose “Customize This Search Folder” from the context menu.Customize This Search Folder
  3. Next, in the popup “Custom Search Folder” dialog, click “Browse” button.
  4. Later, a new dialog box of “Select Folder(s)” will display. In it, you can choose the folders to be searched for emails you haven’t replied.Select Folders
  5. Finally, after selecting, you can just click several “OK” to apply the changes.

Eliminate Frequent Outlook Errors

It is common to receive error messages in your Outlook, such as errors related to sending/receiving failures, errors involving inaccessible Outlook PST file and so on. Therefore, so as to deal with these errors quickly and effectively, you have to learn how to locate and make use of the inbox repair tool. Besides, in case of the inbuilt tool failure, it is suggested to get hold of another excellent external utility, 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 SQL Server repair and outlook repair software products. For more information visit www.datanumen.com

5 responses to “How to Quickly Create a Search Folder for All Unreplied Emails via Outlook VBA”

  1. Thank you! This is helpful. However, I am not able to customize the “criteria” on the folder when I try to “customize this search folder” – any idea how to change that?

  2. Hello – This macro works great but only gets applied to one of my email accounts, in Outlook I have multiple email addresses added and therefore multiple inboxes. How can the macro run so it adds the “Not Read Emails” Folder to each of the email addresses?

Leave a Reply

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