OutlookEX UDF - Find Items

From AutoIt Wiki
Jump to navigation Jump to search

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.


The following parameters define what is searched for and what properties are returned by the function:

Outlook object returned by a preceding call to _OL_Open()
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.
$iObjectClass (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
$sRestrict (Optional)
Filter text to restrict number of items returned (exact match). Can be combined with $sSearchName/$sSearch. 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"
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.
$sSearchName (Optional)
Specify the name of a single property to be searched for the value specified by $sSearchValue (partial match). Can be combined with $sRestrict.
Be sure to specify the property in correct case e.g. "FirstName" is valid, "Firstname" is invalid.
$sSearchValue (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 $sSearchValue is "This" or "is a" or "test".
$sReturnProperties (Optional)
Comma separated list of properties to return (default = depending on $iObjectClass). Be sure to specify the properties in correct case e.g. "FirstName" is valid, "Firstname" is invalid.
$sSort (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.
$iFlags (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
$sWarningClick (Optional)
The entire path (drive, directory, file name and extension) to 'OutlookWarning2.exe' or another exe with the same function (default = None)