Compartir a través de


IPOutlookItemCollection::Restrict (Windows CE 5.0)

Send Feedback

This method creates a new Items collection that contains only items that pass a specified restriction.

HRESULT Restrict(BSTR pwszRestriction,IPOutlookItemCollection** ppolItems);

Parameters

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

    For example, the restriction string [CompanyName] = "Microsoft" returns a collection of items with Microsoft as the company.

  • ppolItems
    [out] Pointer that points to the new collection of items. This is set to NULL if no item passes the restriction.

Return Values

S_OK indicates success. If an error occurs, the appropriate HRESULT is returned. If no item matches the restriction, the return value is S_OK and polItem is set to NULL.

Example

The following code example restricts contacts to those with the company name Microsoft.

void RestrictContacts (IPOutlookApp *polApp)
{
  IFolder *pFolder;
  IPOutlookItemCollection *pItems;

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

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

  // Restrict the collection to Contacts with company set to Microsoft
  polItems->Restrict (TEXT ("[CompanyName] = \"Microsoft\""), &polItems);

  // Release objects
  pFolder->Release ():
  pItems->Release ():
}

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 will not be found using the restriction string [Email1Address]<>someone@example.com, even though "no address" is a logical match for "not someone@example.com."

Requirements

OS Versions: Windows CE 2.0 and later.
Header: Pimstore.h.
Link Library: Pimstore.lib.

See Also

IPOutlookItemCollection | IPOutlookItemCollection Properties

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.