PRB: Rule that Applies to All Messages Cannot Be CreatedLast reviewed: January 7, 1998Article ID: Q177623 |
The information in this article applies to:
SYMPTOMSA rule that applies to all the messages that come into an Inbox cannot be created using any of the helper functions such as HRInsert(), because this type of rule requires that the restriction structure be empty. This is a problem because the HrStringToRestriction() function [used to create a restriction to pass to HRInsert() and other similar functions] fails with MAPI_E_INVALID_PARAMETER when called with a NULL for the restriction string.
CAUSEThe call returns MAPI_E_INVALID_PARAMETER because HrStringToRestriction() expects a string, not a NULL.
RESOLUTIONThe following code allows you to programmatically create a rule that applies to all messages. 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 program.
hr = AllMessageRule(m_lpExchTbl, lpFolder,0,lStateFlags, lpRes,lpActs,"MSFT:TDX Rules",0,""); if (FAILED(hr)) { MessageBox(NULL,"Insert Failed",NULL,MB_OK); goto cleanup; } HRESULT AllMessageRule(IN LPEXCHANGEMODIFYTABLE m_lpExchTbl, IN LPMAPIFOLDER lpFolder, IN ULONG ulSequence, IN ULONG ulState, IN LPSRestriction lpRestriction, IN LPACTIONS lpActions, IN LPSTR lpszProvider, IN ULONG ulLevel, IN LPSTR lpszName) { HRESULT hr = S_OK; SizedROWLIST(1, RowList) = {0}; LPROWENTRY lpRowEntry = NULL; LPROWLIST lpRowList = (LPROWLIST)&RowList; SPropValue rgPropVals[9] = {0}; rgPropVals[0].ulPropTag = PR_RULE_SEQUENCE; rgPropVals[0].Value.ul = ulSequence; rgPropVals[1].ulPropTag = PR_RULE_STATE; rgPropVals[1].Value.ul = ulState; rgPropVals[2].ulPropTag = PR_RULE_CONDITION; rgPropVals[2].Value.ul = (ULONG)lpRestriction; rgPropVals[3].ulPropTag = PR_RULE_ACTIONS; rgPropVals[3].Value.ul = (ULONG)lpActions; rgPropVals[4].ulPropTag = PR_RULE_PROVIDER; rgPropVals[4].Value.lpszA = lpszProvider; rgPropVals[5].ulPropTag = PR_RULE_LEVEL; rgPropVals[5].Value.ul = NULL; rgPropVals[6].ulPropTag = PR_RULE_NAME; rgPropVals[6].Value.lpszA = lpszName; rgPropVals[7].ulPropTag = PR_RULE_USER_FLAGS; rgPropVals[7].Value.ul = NULL; rgPropVals[8].ulPropTag = PR_RULE_PROVIDER_DATA; rgPropVals[8].Value.ul = NULL; lpRowList->cEntries = 1; lpRowEntry = lpRowList->aEntries; lpRowEntry->ulRowFlags = ROW_ADD; lpRowEntry->cValues = 9; lpRowEntry->rgPropVals = (LPSPropValue)rgPropVals; // Modify the RULE table hr = m_lpExchTbl->ModifyTable(0, lpRowList); if (FAILED(hr)) { goto cleanup; } cleanup: ULRELEASE(m_lpExchTbl); RETURN(hr); } Keywords : kbcode EDKAPI Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |