Share via


IPOutlookItemCollection::Find

The Find method finds the first Pocket Outlook item in a collection that passes the specified restriction.

Syntax

HRESULT Find (
  BSTR pwszRestriction,
  IDispatch ** ppolItem
);

Parameters

  • pwszRestriction
    [in] Reference to a null-terminated Unicode string that defines which items to find. The string must contain a Boolean expression that evaluates to TRUE or FALSE for any item. Enclose property names between brackets. You can combine expressions with AND and OR. Comparison operators are the following: <, <=, >, >=, =, <>.

    For example, the restriction string [CompanyName] = "Microsoft" gets the first item that has Microsoft as the company.

  • ppolItem
    [out] Reference to the item found by the method. Set to NULL if no item passes the restriction.

Return Values

This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    The method completed successfully.

Remarks

A restriction match requires that the item include a value for the property. For example, if you do not set the e-mail address for a contact, the contact cannot be found by using the restriction string [Email1Address]<>someone@example.com even though "no address" is a logical match for "not someone@example.com."

Find does not support restrictions based on the following item properties: BodyInk, ReminderTime, Recipients.

Use IPOutlookItemCollection::FindNext to find subsequent items in a collection that pass the restriction.

Example

The following code example shows how to set a specified contact's information.

void SetContactInfo(IPOutlookApp * polApp)
{
    IFolder * pFolder;
    IPOutlookItemCollection * polItems;
    IContact * pContact;

    // Get the Contacts folder.
    polApp->GetDefaultFolder(olFolderContacts, &pFolder);

    // Get the Contacts Items collection.
    pFolder->get_Items(&polItems);

    // Find Contact by LastName.
    polItems->Find(TEXT("[LastName] = \"Sheperdigian\""), 
                   (IDispatch**)&pContact);

    // Make Microsoft the company name.
    pContact->put_CompanyName(TEXT("Microsoft"));

    // Release objects.
    pFolder->Release();
    polItems->Release();
    pContact->Release();
}

Requirements

Smartphone: Windows Mobile 2002 and later
OS Versions: Windows CE 3.0 and later
Header: pimstore.h
Library: pimstore.lib

See Also

How to: Find a Particular PIM Item within a Collection

IPOutlookItemCollection::FindNext

IPOutlookItemCollection

Pocket Outlook Object Model API Interfaces

Last updated on Friday, April 22, 2005

© 2005 Microsoft Corporation. All rights reserved.

Send feedback on this topic to the authors.