🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5310

Get list of new messages in POP3

#5310
From: Jim Dodd
Date: Wed, 22 Sep 2004 19:20
42 lines
2650 bytes
I'm using Indy 9 in BCB6. I can connect to a POP3 mailbox and find the 
number of messages in my mailbox. I can cycle through the messages with 
Retrieve() and read the subject of each message but I never get any 
value for Flags (in the TIdMessage object, I'm checking for the value 
mfRecent to see if a message has recently arrived but Flags is always = 
0) even though I've sent a recent message to the mailbox. No matter how 
many times I use this, I always get the same number for iMsg (the result 
of CheckMessages()) and a value of 0 for NewMsgCount (because idm->Flags 
is always = 0).

Here is my code (the ShowMessage() always shows the same, correct Subjects):

     int NewMsgCount = 0;
     Edit1->Text = String("Wait...");
     Application->ProcessMessages();
     IdPOP31->Connect();
     int iMsg = IdPOP31->CheckMessages();
     if( iMsg > 0 )
     {
         for( int iMsgNum = 1; iMsgNum <= iMsg; iMsgNum++ )
         {
             // also tried using 'this' instead of IdOPOP31
             // in next instruction to no avail
             TIdMessage *idm = new TIdMessage(IdPOP31);
             idm->Clear();
             if( IdPOP31->RetrieveHeader(iMsgNum, idm) )
             {
                 if( idm->Flags.Contains(mfRecent) )
                     NewMsgCount++;
                 ShowMessage(idm->Subject); // always works
             }
             delete idm;
         }
     }
     IdPOP31->Disconnect();
     // display number of recent messages?
     Edit1->Text = String(NewMsgCount);

Can anyone tell me what I'm doing wrong? Thank you.

Jim Dodd
Onset Computer Corp.
Technical Details
Message-ID: <4151d06a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!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-Thread: 11508e,6a75ae9b12954a47,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 22 Sep 2004 15:20:10 -0400
From: Jim Dodd <bcbuilderboy@yahoo.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Get list of new messages in POP3
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.75.243.226
Message-ID: <4151d06a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1095880810 24.75.243.226 (22 Sep 2004 12:20:10 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail