> 4. Using "PpropFindProp" function for "PR_DISPLAY_NAME" found name for
> each public folders.
> 5. Found that "PR_MESSAGE_SIZE" is the one to retrieve public folder
> size propery. But not getting how to use this.
Hi Dan,
Thanks for your inputs.
>4. Using "PpropFindProp" function for "PR_DISPLAY_NAME" found name for
> each public folders.
>
> Where did you get this property from? You should be using
> IMAPIProp::GetProps, or HrGetOneProp.
Here is the code which I used for this
-------------------------------------------------------------------------------
//STEP 1:Initialized MAPI libraries
hr_p = MAPIInitialize (NULL);
//STEP 2: logon to MAPI for enumerating Public Folders
hr = MAPILogonEx(0, "MS Exchange Settings", NULL,
MAPI_LOGON_UI | MAPI_NEW_SESSION | MAPI_EXPLICIT_PROFILE ,
&lpSess);
//STEP 3:Open the MAPI Public Folder store using the IMAPISession
interface
hr_p = HrOpenExchangePublicStore(pSession, &pmdbPublicACL);
//STEP 4: check if its got opened properly using HrGetOneProp
hRes = HrGetOneProp(
pmdbPublicACL,
PR_DISPLAY_NAME,
&tmp);
if (FAILED(hRes))
printf("failed hRes");
printf("I managed to open the folder '%s'\n",tmp->Value.lpszA);
//result got is : I managed to open the folder 'Public Folders'
//STEP 5: open the MAPI Public Folder tree
hr_p = HrOpenExchangePublicFolders (pmdbPublicACL, &pRoot);
//STEP 6: check if its got opened properly using HrGetOneProp
hRes = HrGetOneProp(
pRoot,
PR_DISPLAY_NAME,
&tmp);
if (FAILED(hRes))
printf("failed hRes for public folder");
printf("I managed to open the folder '%s'\n",tmp->Value.lpszA);
//result got is :I managed to open the folder 'All Public Folders'
//STEP 7: get Public folder HierarchyTable using GetHierarchyTable
hr_dir = MAPICALL( pRoot)->GetHierarchyTable( MAPI_DEFERRED_ERRORS,
&lpTable);
//STEP 8: Get the list of public folders using HrQueryAllRows
hr_dir = HrQueryAllRows( lpTable, (LPSPropTagArray)&rgColProps, NULL,
NULL, 0L, &lpRow);
//STEP 9: Use FOR loop iterate and print name and size
for(j = 0; j < lpRow->cRows; j++)
{
LPSPropValue lpDNspv_n = PpropFindProp(
lpRow->aRow[j].lpProps,
lpRow->aRow[j].cValues,
PR_DISPLAY_NAME );
printf("Display Name for pub_fold: '%s'\n", lpDNspv_n->Value.lpszA);
//result got is :Display Name for pub_fold: 'Internet Newsgroups'
Display Name for pub_fold: 'public_folder_1'
Display Name for pub_fold: 'public_folder_2'
/* As you said in mailchain, I need to use
LPSPropValue ppvTemp;
HrGetOneProp(pProp, PR_MESSAGE_SIZE, &ppvTemp);
to get size of each public folder. But not getting what should I
specify pProp value.
*/
-------------------------------------------------------------------------------
Similer way I did for getting mailbox size property and there also as
you said I used HrGetOneProp to get size value. But there to use this
function, first I used "HrMailboxLogon" to get "lpUserMDB" which can be
used as pProp value to fetch mailbox size.
Ex:
hr = HrMailboxLogon(
lpMAPISession,
lpMDB,
pszServerDN,
lpspv->Value.lpszA,
&lpUserMDB);
and then I sued HrGetOneProp to get size
Ex:
hr =
HrGetOneProp(
lpUserMDB,
PR_MESSAGE_SIZE,
&lpProp);
printf("Total Message Size = %d\n",lpProp->Value.l);
Similer way not getting how to use it for PublicFolders.
Please let me know your views on this.
Regards,
Shivaraj
> > 4. Using "PpropFindProp" function for "PR_DISPLAY_NAME" found name for
> > each public folders.
[quoted text clipped - 15 lines]
>
> -- dan
Dan Mitchell - 21 Nov 2006 17:15 GMT
> /* As you said in mailchain, I need to use
> LPSPropValue ppvTemp;
> HrGetOneProp(pProp, PR_MESSAGE_SIZE, &ppvTemp);
> to get size of each public folder. But not getting what
> should I
> specify pProp value.
You need to get PR_ENTRYID from the hierarchy table, that's the entryID
of the folder, and then pass that to OpenEntry to actually open the
folder in question. Then the folder object would be pFolder.
Take a look at the samples here:
ftp://ftp.microsoft.com/developr/MAPI/Samples/MFCAPPS/MFCAPPS.ZIP
(weirdly, you may have to use command-line FTP to get that, just
putting the link into IE fails)
and here:
http://blogs.msdn.com/stephen_griffin/archive/2006/06/07/621138.aspx
for more examples of how to do this. Also, Inside MAPI is a good book
on this stuff. (or just search support.microsoft.com for "mapi sample")
-- dan
shivaraj - 23 Nov 2006 05:52 GMT
Hi Dan,
I am able to get size info for public folders by callihng
HrMAPIFindSubfolderEx for root folder and passing each public folders
as third argument. and then called OpenEntry as you said. This way I
got size for all public folders in my exchange setup and also verified
the same with Exchange System Manager for correctness of these values.
I have attached sample code for STEP-9 here... please let me know if
you feel anything fishy here....
----------------------------------------------
//STEP 9: Use FOR loop iterate and print name and size
for(j = 0; j < lpRow->cRows; j++)
{
LPSPropValue lpDNspv_n = PpropFindProp(
lpRow->aRow[j].lpProps,
lpRow->aRow[j].cValues,
PR_DISPLAY_NAME );
printf("Display Name for pub_fold: '%s'\n",
lpDNspv_n->Value.lpszA);
/*result got is :Display Name for pub_fold: 'Internet
Newsgroups'
Display Name for pub_fold:
'public_folder_1'
Display Name for pub_fold:
'public_folder_2' */
char * l_strFullPath =
lpDNspv_n->Value.lpszA;
hr_p = HrMAPIFindSubfolderEx (pRoot,
PATH_SEP, (LPCSTR)l_strFullPath, &cbeid, &lpeid);
if (FAILED (hr_p))
{
printf("MAPI Public Folder Access Error ");
}
hr_p = pmdbPublicACL->OpenEntry ( cbeid, lpeid,
NULL, MAPI_MODIFY, &ulObjType,(LPUNKNOWN*)&pFolder );
if (FAILED (hr_p))
{
printf("MAPI Public Folder Access Error on %s for Profile
\n",l_strFullPath);
}
LPSPropValue ppvTemp;
HrGetOneProp(pFolder, PR_MESSAGE_SIZE, &ppvTemp);
printf("public folder Size = %d\n",ppvTemp->Value.l);
} //end of for loop
---------------------------------------------------------------
Regards,
Shivaraj
----------------------------------------------
> > /* As you said in mailchain, I need to use
> > LPSPropValue ppvTemp;
[quoted text clipped - 22 lines]
>
> -- dan
Dan Mitchell - 23 Nov 2006 20:03 GMT
> I have attached sample code for STEP-9 here... please let me know if
> you feel anything fishy here....
That looks good to me -- as long as all the folders you need to measure
are at the top level, that should be fine.
(If you need to get the size of a subfolder, you'll need to use
GetHierarchyTable to get child folders and then do the same sort of thing
looping over all the child folders).
-- dan