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:
Workaround Solution:
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:
Scope | Description |
---|---|
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 & ")"
You can use an Inputbox to enter the values to count back:
folder:Inbox received:3/30/2020..4/4/2020
Sub UnifiedInbox() Dim myOlApp As New Outlook.Application daysno = InputBox("Enter the days, separate with comma, the larger number first") iDay = Split(daysno, ",") date1 = Date - iDay(0) date2 = Date - iDay(1) txtsearch = "folder:Inbox received:" & date1 & ".." & date2 myOlApp.ActiveExplorer.Search txtsearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
Or enter the dates, in short date format of m/d/yy or m/d/yyyy
folder:Inbox received:4/1/20..4/4/20
Sub UnifiedInbox() Dim myOlApp As New Outlook.Application daysno = InputBox("Enter the dates, separated with a comma, the oldest date first") iDay = Split(daysno, ",") date1 = iDay(0) date2 = iDay(1) txtsearch = "folder:Inbox received:" & date1 & ".." & date2 myOlApp.ActiveExplorer.Search txtsearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
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
Those who find macros and VBA a bit scary can try out our Outlook Add-in "Unified Inbox for Outlook". It uses the same search folder approach, but it's just neatly packaged for easy installation and use.
Check out https://inbox.fgh.ee/
It's not perfect but at least it's something :-)
I set this up a while back but today realized it's not working quite as expected. One of the Inboxes is for a Gmail account. When I go to that Inbox in Outlook, or direct to Gmail, there I can find a particular email with the Subject line [email I want to see]. it is labeled Important. However, when I use the macro as described above that email does not appear in the results. i.e. when I Search for the Subject or words in the body the email is not found. I assume this has something to do with the Important label, but what's the cure so that all Inbox emails are identified by the above macro?
Dear Outlook users. Could anyone confirm that the Sub
UnifiedInbox()
also works in Outlook 365? I had setup several unified folders in office 2016, but now, the subroutine makes outlook crash/restart, at least on my end.Thanks.
it's working here, in the insider fast build. I'll check it on a current build.
Diane,
I have been using your great fix for years for a unified INBOX. However we just upgraded to Office 365 for Exchange form Outlook 2010 from Exchange. It is not working with 365? Any help appreciated.
Steve
It should work... Do you have macro security adjusted? Does it not run or not find anything? Do you receive any error messages?
No error messages. It seems to load. But is not pulling emails from all my inboxes. We do have 2 exchange accounts. It worked perfectly with Outlook 2010.
Are both accounts in as accounts? It won't work for shared mailboxes.
Are both accounts set up as cached mode?
If I create a unified inbox with a MAPI account (default) and three IMAP accounts, will this result in the IMAP emails getting categories and custom flags? That would make it worthwhile and preferable to the redirect system where I have to set up POP3 send only accounts in Outlook. Is that option available?
I would like to run the sub on startup, but I get an error (429 ActiveX element could not be created). How do I wait for the ActiveExplorer to exist?
Possibly, since there is nothing in the code that would use any control. What code are you using to trigger it at startup?
Thank you for your answer.
I have added the following lines to 'ThisOutlookSession':
This prevents outlook from opening and finally yields the error mentioned above.
Hi,
Thanks for this. Zero experience with VBA but I managed to set up the unified inbox on my first try!
However, I can't get the unified sent box macro to work. It says 'we couldn't find what we were looking for'. Do you have any tips?
Are you using the general 'this week' macro or one that includes other criteria ?
Hi Diane. Thanks for sharing this solution. To be honest I did not test it and unlikely will do due to its complexity even being familiarized with VBA.
I have a similar problem in my office because colleagues have some difficulties in using IMAP as they want to work with at least five email accounts - they use POP3 instead.
Well, if you allow me, I have tested my own solution that consists:
1- Create a new PST to Outlook;
2- Create a rule that copies every single incoming message to the new PST;
3- Place the new PST box to favourites;
That's all!
I can't understand why Microsoft didn't create the same solution that works perfectly on Outlook for iOS.
All the best and thank you for keeping this site working. I love it !
>> they use POP3 instead.
if they are using POP, then no ned for this:
>> Create a rule that copies every single incoming message to the new PST
Just set the accounts to deliver to the same pst - this avoids all of the problems associated with rules and creating duplicated messages. Replies will be sent from the proper account - they will need to select the correct account for new messages.
iOS (and mac, android) apps don't have the same limitations that Outlook does (since thye were built new from the ground up), mostly due to legacy code and how search works. They are working on improving search, so we might see some changes in the future.
FWIW, i have 5 accounts in my profile (and 3 shared mailboxes) and just added each inbox to the Favorites instead of using instant search to create a unified view. I ordered them in order of importance and go down the list to work the inboxes.