HOWTO: How to Create a Restriction

Last reviewed: January 7, 1998
Article ID: Q177622
The information in this article applies to:
  • Exchange Development Kit (EDK), version 5.0

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.

MORE INFORMATION

Steps for Creating a Restriction

  1. Create a string that contains the property and the value you want to look for.

  2. 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
          Addrlkup.lib
          Edkguid.lib
          Rulecls.lib
          Edkdebug.lib
          Edk.h
    
    

REFERENCES

For more information, please see the following topics in the Microsoft Developer Network Library (MSDN). These topics can be found in the Win32 Messaging (MAPI) section of the Platform SDK.

  • Starting a MAPI Session
  • Opening a Message Store
  • Opening the Default Message Store
  • Opening a Folder


Additional query words: Restriction Restrictions HrStringToRestriction
Keywords : kbcode EDKAPI
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 7, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.