by mazz » Tue, 17 Aug 2004 17:33:39
I would like to read all the messages in Inbox.
But I can't read more than 10 messages because QueryRows can set up to only
10 rows
How can i read all the messages?
My code is like this:
pSession->GetMsgStoresTable(MAPI_UNICODE, &m_pMsgStoresTable);
SizedSPropTagArray(2, Columns) = {2,{PR_DISPLAY_NAME,PR_ENTRYID}};
hRes = m_pMsgStoresTable->SetColumns((LPSPropTagArray)&Columns, 0);
while( true )
{
hRes = m_pMsgStoresTable->QueryRows(1, 0, &pRows);
if( FAILED( hRes ) || pRows->cRows != 1 ) break;
LPSPropValue lpProp = &pRows->aRow[0].lpProps[0];
FreeProws(pRows);
if( _tcscmp( lpProp->Value.LPSZ, _T("SMS") ) == 0 ) break;
}
hRes = pSession->OpenMsgStore(0, pRows->aRow[0].lpProps[1].Value.bin.cb,
(ENTRYID*)pRows->aRow[0].lpProps[1].Value.bin.lpb, NULL, MDB_NO_DIALOG |
MAPI_BEST_ACCESS, &pMsgStore);
static SizedSPropTagArray(1, sContents) = { 1, {
PR_ENTRYID } };
hRes = pMsgStore->GetReceiveFolder(NULL,0,&cbEntryID,&lpEntryID,NULL );
hRes = pMsgStore->OpenEntry(cbEntryID,lpEntryID,NULL,0,&ulObjType,(LPUNKNOWN
FAR *)&lpFolder);
hRes = lpFolder->GetContentsTable( 0, &lpTable );
lpTable->GetRowCount(0,&numberOfMessages); // The number of messages;
hRes = lpTable->SetColumns( (LPSPropTagArray)&sContents, 0 );
hRes = lpTable->QueryRows( numberOfMessages, 0, &pRows );
lpTable->Release();
for(int k=0;k<numberOfMessages;k++){
hRes = pMsgStore->OpenEntry( pRows->aRow[k].lpProps[0].Value.bin.cb,
(LPENTRYID)pRows->aRow[k].lpProps[0].Value.bin.lpb,
NULL,
0,
ulObjType,
(LPUNKNOWN FAR *)&lpMessage);
SizedSPropTagArray(1,rgTags_SENDER) = {1,PR_SENDER_NAME};
hRes = lpMessage->GetProps((LPSPropTagArray) &rgTags_SENDER, MAPI_UNICODE,
&pcount, &rgprops);
senderID=space->textTostr(rgprops->Value.lpszW);
SizedSPropTagArray(1,rgTags_SUBJECT) = {1,PR_SUBJECT};
hRes = lpMessage->GetProps((LPSPropTagArray) &rgTags_SUBJECT, MAPI_UNICODE,
&pcount, &rgprops);
add(new SmsMessage(senderID, subject ));
}