🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Decoding email subject string (or generally an email message)

#6523
From: Remy Lebeau (TeamB)
Date: Thu, 05 May 2005 21:10
36 lines
2584 bytes
"Danila Vershinin" <danprep@yahoo.com> wrote in message
news:427a87c7@newsgroups.borland.com...

> void __fastcall TForm1::MailConnected(TObject *Sender)
> {
> MailCount = Mail->CheckMessages();
> }

The error you are seeing is caused by a bug in your own code, not Indy's.
You cannot call CheckMessage() from the OnConnected event handler.  This is
because TIdPOP3 overrides the TIdTCPClient::Connect() method to perform
additional operations needed to log into the POP3 server.  The first thing
TIdPOP3::Connect() does is to call TIdTCPClient::Connect() to establish the
actual socket connection.  After TIdTCPClient::Connect() returns,
TIdPOP3::Connect() then reads the server's Greeting and sends the
username/password.  Because the OnConnected event is triggered by
TIdTCPClient::Connect(), not TIdPOP3::Connect(), you are calling
CheckMessages() before TIdPOP3 has a chance to read the Greeting or login.
As such, when CheckMessages() attempts to get the server's reply to the STAT
command, it is reading the server's Greeting instead.  That is why you get
the parsing error.

To fix the problem, you must not call CheckMessages() until after
TIdPOP3::Connect() returns.  That means moving your call to CheckMessages()
into your button OnClick handler instead, ie:

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
        Mail->Connect();
        Mail->CheckMessages(); // <-- wait until Connect() returns first
        //...
    }


Gambit
Technical Details
Message-ID: <427a8b73$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <427a3ba1@newsgroups.borland.com> <427a5557$1@newsgroups.borland.com> <427a6ac7@newsgroups.borland.com> <427a799c$1@newsgroups.borland.com> <427a87c7@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ebae1c5dc81fe23
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <427a3ba1@newsgroups.borland.com> <427a5557$1@newsgroups.borland.com> <427a6ac7@newsgroups.borland.com> <427a799c$1@newsgroups.borland.com> <427a87c7@newsgroups.borland.com>
Subject: Re: Decoding email subject string (or generally an email message)
Date: Thu, 5 May 2005 14:10:53 -0700
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <427a8b73$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1115327347 68.69.17.41 (5 May 2005 14:09:07 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail