Microsoft KB Archive/177622

= How To Create a Restriction =

Article ID: 177622

Article Last Modified on 3/21/2005

-

APPLIES TO


 * Microsoft Exchange Development Kit 5.5

-



This article was previously published under Q177622



SUMMARY
Restrictions are used by Exchange to limit the rows returned in a table. Restrictions are used throughout the product for determining the conditions for rules, searching for messages, and for creating views of messages. This article describes how to create a restriction and provides a code example. The code provided is not complete. It assumes that you already have a handle to a MAPI session, a pointer to the message store, a pointer to the folder the rule is to be applied to, and that you will release the appropriate structures before exiting the function.



Steps for Creating a Restriction
 Create a string that contains the property and the value you want to look for.  Call HrStringToRestriction with the restriction string, NULL, and a pointer to a restriction. NULL for the second parameter lets HrStringToRestriction create the restriction and allocate memory for the restriction.

LPSRestriction  lpRes =         NULL; hr = CreateRestriction(lpRes);

HRESULT CreateRestriction(LPSRestriction lpRes) {        HRESULT hr = NULL;

// hr = HrStringToRestriction("PR_SENDER_NAME } \"Bugs Bunny\"",         //                             NULL,         //                             &lpRes); hr = HrStringToRestriction("PR_SUBJECT } \"Test\"",                        NULL, &lpRes);

if (FAILED(hr)) {           MessageBox(NULL,"Restriction Failed",NULL,MB_OK); return hr; }

if (lpRes->rt = RES_CONTENT) {          lpRes->res.resContent.ulFuzzyLevel =   FL_SUBSTRING   | FL_IGNORECASE | FL_LOOSE; }        return hr; }

Note: To use this code, the following libraries and headers are required:

 Mapi32.lib Uuid.lib Version.lib Edkmapi.lib Edkutils.lib</li> Addrlkup.lib</li> Edkguid.lib</li> Rulecls.lib</li> Edkdebug.lib</li> Edk.h</li></ul> </li></ol>

<div class="references_section">