I have encountered a "quirk" in Outlook 2013 when attempting to have Outlook open a new window for a search (when a button is clicked in my Outlook add-in). The search does not initiate; the search term appears in the box but only the inbox contents are displayed (albeit with highlighting of my search term if relevant to Inbox items). If I then change anything in the search box (e.g. add then remove a quote) it kicks off correctly (i.e. filters the Output to my search).
I cannot reproduce this issue in Outlook 2010, nor if I call the same code via a standalone EXE. Also, it works correctly if I launch the search to an existing Explorer window.
Here is my code (simplified):
OutlookApp := GetActiveOleObject(OUTLOOK_APPLICATION_CLASS);
OLNameSpace := OutlookApp.GetNameSpace(MAPI_NAMESPACE);
OLNameSpace.Logon;
objFolder := OLNameSpace.GetDefaultFolder(olFolderInbox);
objExplorer := OutlookApp.Explorers.Add(objFolder, olFolderDisplayNoNavigation);
objExplorer.Search(sSearchText, olSearchScopeAllFolders);
objExplorer.Activate;
...
While debugging, I have tried:
I would like to hear of any suggestions for workarounds, or anything I have missed...
Thanks
Resolved by delaying objExplorer.Search() (by creating a new explorer and posting a message to the window, which then enacts objExplorer.Search). Ugly, but works :-(