SetProps doesn't work for the last folder from the hierarchy ?

  • Thread starter Thread starter kistvan
  • Start date Start date
K

kistvan

Hi,

I encountered some problems when I tried to programaticaly change the
PR_DEF_POST_DISPLAYNAME and PR_DEF_POST_MSGCLASS properties for the contacts
folder structure: these properties were properly changed for all folders,
subfolders except the last one from the hierarchy.
Ex: Contacts -> SubFolderContacts -> SubSubFolderContacts
The properties were properly changed for Contacts and SubFolderContacts but
it weren't changed for SubSubFolderContacts.
Note: in the application I didn't receive any error message when I tried to
change the properties.

Regards,
Istvan
 
Below is a part of the code which is used:

- the function is first called from the main application for the root folder (Contacts)

HRESULT setMsgClassForFolder(ULONG cbEID,LPBYTE lpEID,LPMAPIFOLDER pFolder)
{
hr = pFolder->OpenEntry( cbEID, (LPENTRYID)lpEID, 0, MAPI_BEST_ACCESS, &ulObjType, (LPUNKNOWN*)( LPMAPIPROP *) &lpContFolder);

// this doesn't work for the last folder from the hierarchy
SPropValue prop1[2];
prop1[0].ulPropTag = PR_DEF_POST_DISPLAYNAME;
prop1[0].Value.lpszA = "My custom form";
prop1[1].ulPropTag = PR_DEF_POST_MSGCLASS;
prop1[1].Value.lpszA = "IPM.Contact.My custom form";

hr = pFolder->SetProps( 2, prop1, NULL );
pFolder->SaveChanges( KEEP_OPEN_READWRITE );

hr = lpContFolder->GetContentsTable( 0, & lpContTable);
hr = lpContTable->GetRowCount( 0, &ulContRows);

LPMAPITABLE lpContFolderTable = NULL;
ULONG ulContFolderRows = 0L;
LPSRowSet pContFolderRows;

hr = lpContFolder->GetHierarchyTable( 0, &lpContFolderTable);
hr = lpContFolderTable->GetRowCount( 0, &ulContFolderRows);

SizedSPropTagArray( 1, contFolderPropTag) = {1,{PR_ENTRYID}};

hr = lpContFolderTable->SetColumns( (LPSPropTagArray)&contFolderPropTag, 0 );

hr = HrQueryAllRows( lpContFolderTable,NULL,NULL,NULL, ulContFolderRows,&pContFolderRows);

for( int fIdx = 0; fIdx < pContFolderRows->cRows; fIdx++)
{
ULONG cbContFolderEID = 0L;
LPBYTE lpbContFolderEID = NULL;

cbContFolderEID = pContFolderRows->aRow[fIdx].lpProps[0].Value.bin.cb;
lpbContFolderEID = pContFolderRows->aRow[fIdx].lpProps[0].Value.bin.lpb;
hr = setMsgClassForFolder( cbContFolderEID, lpbContFolderEID,lpContFolder);
}
... release stuff
return hr;
}
 
Back
Top