Applies to Microsoft Outlook 2013, Outlook 2010, Outlook 2007
Older versions of Outlook have the Activities tab which will find all Outlook items associated with a particular contact. Activities are broken in Outlook 2010 and removed from Outlook 2013.
While you can use the Social Connector's People pane to see all messages, appointments, and attachments from a person, you can also use Instant Search. Type from:(name) or from:(email@address) in the Instant search field.
This macro makes it easier to use Instant Search to find messages for a selected contact, by entering the contact's name or email address into the Instant Search field in the Inbox.
If you need persistent search results, see How to create an Outlook search folder using VBA.
This macro can use any valid Instant search criteria. You just need to replace or edit the txtSearch line. To find messages to and from a contact, use txtSearch = "from:" & strFilter & " OR to:" & strFilter
Search for messages from contact macro
- Open the VBA editor using Alt+F11
- Right click on Project1 and choose Insert > Module
- Paste the following code into the module.
- Set macro security to low to test the code, then use Selfcert to sign the macro before change security to high.
- Add the macro to a ribbon, QAT, or toolbar button.
- Select a contact and run the macro.
Sub SearchByAddress() Dim myOlApp As New Outlook.Application Dim ns As Outlook.NameSpace Dim strFilter As String Dim oContact As Outlook.ContactItem Set ns = myOlApp.GetNamespace("MAPI") Set oContact = ActiveExplorer.Selection.item(1) ' use oContact.FullName to search on the name strFilter = oContact.Email1Address Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox) txtSearch = "from:" & strFilter myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub
If you are still using Journal, you can tweak the macro to search the journal for items associated with the contact. Change the contact field to Full name and the folder to journal.
strFilter = oContact.FullName Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderJournal) ' change the search filter to look for the contact name txtSearch = "contactnames:(" & strFilter & ")"
Valid Search Scopes
Outlook 2010 and Outlook 2013 use 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.|
|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.|
Outlook 2007 users are are limited to olSearchScopeAllFolders and olSearchScopeCurrentFolder.