🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10334

Accessing MAPI folders other than Inbox

#10334
From: Alfred Thomas
Date: Thu, 15 Apr 2004 12:53
50 lines
2764 bytes
Hi

I am using MAPI functions to iterate through all the e-mails in
the Inbox. I would like to do the same for other Personal
folders other than Inbox. Can anyone please tell me how to iterate
through all the Personal folders? 
Here is the code I use to get to the Inbox

   hr = MAPIInitialize(NULL);
   if(hr) throw Exception("Error: MAPIInitialize");
   hr = MAPILogonEx(0, NULL, NULL, MAPI_ALLOW_OTHERS | MAPI_LOGON_UI | MAPI_USE_DEFAULT, &lpSession);
   if(hr) throw Exception("Error: MAPILogonEx");

   hr = lpSession->GetMsgStoresTable(0, &lpTable);
   if(hr) throw Exception("Error: GetMessageStores");

   hr =  lpTable->SetColumns(   (LPSPropTagArray)&sStores, 0 );
   if(hr) throw Exception("Error: SetColumns");

   hr = lpTable->QueryRows( 1, 0, &lpRows );
   if(hr) throw Exception("Error: QueryRows");

   lpTable->Release();

   hr = lpSession->OpenMsgStore(0, lpRows->aRow[0].lpProps[1].Value.bin.cb,
                                (LPENTRYID)lpRows->aRow[0].lpProps[1].Value.bin.lpb,
                                NULL, MDB_WRITE, &lpMsgStore);
   if(hr) throw Exception("Error: OpenMsgStore");


   hr = lpMsgStore->GetReceiveFolder(NULL, 0, &cbEntryID, &lpEntryID, NULL );
   if(hr) throw Exception("Error: GetReceiveFolder");

   hr = lpMsgStore->OpenEntry( cbEntryID, lpEntryID, NULL, 0, &ulObjType, (LPUNKNOWN FAR *)&lpFolder);
   if(hr) throw Exception("Error: OpenEntry");

   hr =  lpFolder->GetContentsTable( 0, &lpTable   );
   if(hr) throw Exception("Error: GetContentsTable");

   hr =  lpTable->SetColumns(   (LPSPropTagArray)&sContents, 0 );
   if(hr) throw Exception("Error: SetColumns");

   hr = lpTable->QueryRows( 10, 0, &lpRows );
   if(hr) throw Exception("Error: QueryRows");

By the way, when I include ekd.h I get compiler errors.

Regards
Alfred Thomas
Technical Details
Message-ID: <407e85b8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,16496c20fcd3ac5,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-15 06:10:00 PST
From: "Alfred Thomas" <alfred@fischerint.co.za>
Sender: "Alfred Thomas" <alfred@fischerint.co.za>
Reply-To: "Alfred Thomas" <alfred@fischerint.co.za>
Subject: Accessing MAPI folders other than Inbox
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 196.25.217.126     
X-Forwarded-For: 192.96.150.189
NNTP-Posting-Host: 207.105.83.66
Message-ID: <407e85b8$1@newsgroups.borland.com>
Date: 15 Apr 2004 05:53:12 -0700
X-Trace: newsgroups.borland.com 1082033592 207.105.83.66 (15 Apr 2004 05:53:12 -0700)
Lines: 50
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail