I have an Outlook COM addin and would like to be able to read the current search box text value that the user has enter. How do I do that?
The Outlook object model doesn't provide anything for retrieving the search criteria. The best what you could do is to get the filter string for the current view of the folder or explorer window. The Explorer.CurrentView property returns or sets a View
object representing the current view. And the Folder.CurrentView property returns a View
object representing the current view. For example:
Private Sub FilterViewToLastWeek()
Dim objView As View
' Obtain a View object reference to the current view.
Set objView = Application.ActiveExplorer.CurrentView
' Set a DASL filter string, using a DASL macro, to show
' only those items that were received last week.
objView.Filter = "%lastweek(""urn:schemas:httpmail:datereceived"")%"
' Save and apply the view.
objView.Save
objView.Apply
End Sub
The View
object allows you to create customizable views that allow you to better sort, group and ultimately view data of all different types. There are a variety of different view types that provide the flexibility needed to create and maintain your important data.
olTableView
) allows you to view data in a simple field-based table.olCalendarView
) allows you to view data in a calendar format.olCardView
) allows you to view data in a series of cards. Each card displays the information contained by the item and can be sorted.olIconView
) allows you to view data as icons, similar to a Windows folder or explorer.olTimelineView
) allows you to view data as it is received in a customizable linear time line.Views are defined and customized using the View
object's XML property. The XML
property allows you to create and set a customized XML schema that defines the various features of a view.
The View.Filter property returns or sets a string value that represents the filter for a view.
The value of this property is a string, in DAV Searching and Locating (DASL) syntax, that represents the current filter for the view. For more information about using DASL syntax to filter items in a view, see Filtering Items.
Also you may find a similar post helpful.