Skip to content

Instantly share code, notes, and snippets.

@eram
Last active September 11, 2025 17:39
Show Gist options
  • Select an option

  • Save eram/ef7f2789754623b22e4a79daee85acd6 to your computer and use it in GitHub Desktop.

Select an option

Save eram/ef7f2789754623b22e4a79daee85acd6 to your computer and use it in GitHub Desktop.
Outlook Unified Inbox Macro
' This macro creates a "unified inbox" - a search across all inboxes and sent items.
' Steps to use it:
' 1. Enable developer tab to see VBA console:
' Options > Customize Ribbon >
' Enable the selection field before “Developer” and OK.
' 2. Add macro:
' From the Developer tab open Visual Basic dialog
' Open VBA Add the Sub below to General context
' 3. Enable macros:
' Options > Trust Center > Trust Center Settings > Macro Settings
' Choose 'Notifications for all macros' and OK.
' 4. Add the macro to Quick Access Toolbar:
' Options > Quick Access Toolbar
' Choose commands from 'Macros'
' Select the macro 'Project1.ThisOutllokSession.UnifiedInbox' and [add] it to the right side pane.
' Select [Modify] and choose an icon and display name. and OK.
Sub UnifiedInbox()
Dim myOlApp As New Outlook.Application
Dim tDate As Date
tDate = Date - 14 '7 days ago
txtSearch = "folder:Inbox received:(>" & tDate & ")" & " OR folder:Sent sent:(>" & tDate & ")"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeCurrentFolder
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub
@jerryhall
Copy link

Thank you for this. Is there a way to include a command that also only displays 'unread' emails in the same macro?

@gfmoore
Copy link

gfmoore commented Sep 24, 2022

Cool. I couldn't get it to work at first, but I had Windows Search disabled (such a resource hog). However on enabling and waiting a while for WSearch to do it job it all suddenly worked. Thanks.

@54437698
Copy link

Thank you, just what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment