Everyone wants a unified inbox. Outlook doesn't have anything built in, search folders are per-message store only, and won't work for multiple email accounts. Instant search will search multiple data files, but you need to create the instant search each time you want to use it.
Vote for a Unified Inbox feature in Outlook 2016: Unified Inbox for Outlook 2016
This is a solution to a very popular question of how to create a Unified Inbox in Outlook 2010. It was posted in the TechNet forums by oju2. While not quite the same as a true Unified Inbox for all email accounts, it has one advantage a true unified inbox does not offer: a very easy way to filter out the mail you don't want to see in a unified view by adding additional queries to the txtSearch line in each macro.
This solution could easily be adapted to apply any frequently used search conditions to a folder.
To use, press Alt+F11 to open the VBA editor, expend Project1 and paste the code into ThisOutlookSession. Add Buttons to Your ribbon or QAT to call the macros to quickly enable the Unified Inbox search when needed. Remember: you need to have macro security set on Low, Warn, or sign the macros using SelfCert.
See How to use Outlook’s VBA Editor for complete details.
First let's agree that Unified Inbox is no more than a particular "VIEW" of your Inbox mails on different account. So this is the same as querying your Inboxes. So we can resolve this by doing a simple global query:
1) Type the following in the search box: folder: (Inbox) received: (this week)
2) Press Ctr+Alt+A to or click All Mailboxes button (Outlook 2013) or All Mail Folders (Outlook 2010).
3) Hit enter and you should see your Unified inbox for all mails received this week.
A more elaborate solution to automate this is to do a Macro. This is the code you need:
The code for a UNIFIED INBOX:
Sub UnifiedInbox() Dim myOlApp As New Outlook.Application txtSearch = "folder:Inbox received: (this week)" myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
The code for a UNIFIED SENT BOX:
Sub UnifiedSentbox() Dim myOlApp As New Outlook.Application txtSearch = "folder: (Sent Mail) sent: (this week)" myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
Valid Search Scopes
In Outlook 2010 and newer you can choose between the following search scopes:
|olSearchScopeCurrentFolder||Limit the search to the currently selected folder.|
|olSearchScopeSubfolders||Limit the search to the currently selected folder and its subfolders. To search all folders in one data file, select the top level of the pst.|
|olSearchScopeCurrentStore||Limit the search to the current mailbox.|
|olSearchScopeAllFolders||Search all folders (of the current folder type). This search includes all data stores that are enabled for search.|
|olSearchScopeAllOutlookItems||Search all Outlook items in all folders in stores that are enabled for search.|
In Outlook 2007, you are limited to olSearchScopeAllFolders and olSearchScopeCurrentFolder
Create a macro for any frequently used Instant Search
You can easily use this macro to create a frequently used search and assign it to a button. You can use instant search to get the criteria then copy and paste it in txtSearch line. When a search query includes double quotes, replace them with parenthesis.
For example, category:="MTWT" becomes category:(MTWT)
Sub SearchByCategory() Dim myOlApp As New Outlook.Application txtSearch = "category:(Business)" myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
Use this code to search (in the current folder) for mail received within the last 7 days.
Sub LastSevenDays() Dim myolApp As New Outlook.Application Dim tDate As Date tDate = Date - 7 '7 days ago txtSearch = "folder:Inbox received: (>" & tDate & ")" myolApp.ActiveExplorer.Search txtSearch, olSearchScopeCurrentFolder Set myolApp = Nothing End Sub
To find messages between two dates, use this string:
txtSearch = "received: (" & Date - 14 & ".." & Date - 7 & ")"
Merged with the code to paste the clipboard contents into a message from "Paste clipboard contents using VBA", this string sample would search for the text that is on the clipboard. Combine it with predefined search terms like this:
txtSearch = "received: (" & tDate & ".." & Date & ") " & strPaste
Don't forget to set a Reference to the Forms library. If you receive a "User-defined type not defined" you are missing the reference to Microsoft Forms 2.0 Object Library. If its not listed, add C:\Windows\System32\FM20.dll or C:\Windows\FM20.dll as a reference. "Paste clipboard contents using VBA" has screenshots and more details instructions.
Sub SearchClipboard() Dim myOlApp As New Outlook.Application Dim strPaste Dim DataObj As MSForms.DataObject Set DataObj = New MSForms.DataObject DataObj.GetFromClipboard strPaste = DataObj.GetText(1) txtSearch = strPaste myOlApp.ActiveExplorer.search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
How to use the macros on this page
First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.
The macros on this page should be placed in a module.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
- Add a button to the ribbon or toolbar for the macro then click to run it.
More information as well as screenshots are at How to use the VBA Editor