I know how to do a search using the Outlook.AdvancedSearch()
method. What I want is based on the parameters for my search to populate the build in advanced find dialog with VBA code, as seen below.
What I want is in the end of the search for the end user to select and move from the results selectively.
Edit
If this is not possible (as my searches indicate) then how can I save the results into a search folder? When I use the Search.Save()
method and the folder already exists, then I get an error. At least I would like the make the search folder active when the search is complete.
You can parse a folder within the namespace ns
with this kind of code:
ns.Folders("Personal Folders").Folders("Inbox")
Found in this thread: Access Outlook default folder
Thus, you can check if your search folder already exists before creating it.
You can also prevent the error or handle it, for instance:
On Error Resume Next
'Create folder (won't raise error if already exists)
On Error GoTo 0
Eventually, to activate the search folder, you can use the CurrentFolder
property:
Sub ChangeCurrentFolder()
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myolApp.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderCalendar)
End Sub
See MSDN for more information.