OutlookEX UDF - Find Items
Here you'll find detailed information on how to find items which then can be processed by further functions.
Function _OL_ItemFind
Finds items (contacts, appointments ...) in the specified folder (and - optional - any subfolder) and returns the requested properties of the found items in an array.
Parameters
The following parameters define what is searched for and what properties are returned by the function:
- $oOL
- Outlook object returned by a preceding call to _OL_Open()
- $oOL_Folder
- Folder object as returned by _OL_FolderAccess or full name of folder where the search will be started. If you want to search a default folder you have to specify the folder object.
- $iOL_ObjectClass (Optional)
- Class of items to search for. Defined by the Outlook OlObjectClass enumeration (default = $olContact). Examples:
- $olAppointment - Represents an AppointmentItem object
- $olContact - Represents a ContactItem object
- $olMail - Represents a MailItem object
- $olTask - Represents a TaskItem object
- $sOL_Restrict (Optional)
- Filter text to restrict number of items returned (exact match). Can be combined with $sOL_SearchName/$sOL_Search. The filter can be a Jet query or a DASL query with the @SQL= prefix (which isn't described here).
- Jet query language syntax:
- Restrict filter: Filter LogicalOperator Filter ...
- LogicalOperator: And, Or, Not. Use ( and ) to change the processing order
- Filter: "[property] operator 'value'" or '[property] operator "value"'
- Operator: <, >, <=, >=, <>, =
- Example: "[Start]='2011-02-21 08:00' And [End]='2011-02-21 10:00' And [Subject]='Test'"
- See: http://msdn.microsoft.com/en-us/library/cc513841.aspx - "Searching Outlook Data" or http://msdn.microsoft.com/en-us/library/bb220369(v=office.12).aspx - "Items.Restrict Method"
- N.B.:
- Pass time as HH:MM, HH:MM:SS is invalid and returns no result.
- Some properties can't be used in a filter (e.g. Body, Categories, HTMLBody) and will cause an error. Please check the "Items.Restrict Method" link above.
- $sOL_SearchName (Optional)
- Specify the name of a single property to be searched for the value specified by $sOL_SearchValue (partial match). Can be combined with $sOL_Restrict.
- Be sure to specify the property in correct case e.g. "FirstName" is valid, "Firstname" is invalid.
- $sOL_SearchValue (Optional)
- String value to search for. All items are returned where the string can be found at any position of the property e.g. if property "Subject" has the value of "This is a test" then the item will be found if $sOL_SearchValue is "This" or "is a" or "test".
- $sOL_ReturnProperties (Optional)
- Comma separated list of properties to return (default = depending on $iOL_ObjectClass). Be sure to specify the properties in correct case e.g. "FirstName" is valid, "Firstname" is invalid.
- $sOL_Sort (Optional)
- The name of the property by which to sort, which may be enclosed in brackets, for example, "[CompanyName]". User-defined properties that contain spaces must be enclosed in brackets. After the property the optional string "True" to sort descending (default = None) might follow. E.g. "[Subject], True" sorts the result descending on the subject.
- $fOL_Flags (Optional)
- Flags to set different processing options. Can be a combination of the following:
- 1 - Subfolders will be included
- 2 - Row 1 contains column headings. Therefore the number of rows/columns in the table has to be calculated using UBound
- 4 - Just return the number of records. You don't get an array, just a single integer denoting the total number of records found