Re: Attachments and POP3->Delete

Giganews Newsgroups
Subject: Re: Attachments and POP3->Delete
Posted by:  Remy Lebeau \(TeamB\) (
Date: Sat, 27 Sep 2008

"duf" <d…> wrote in message news:1A7A14259064E340d…

> But there is problem when I receive one message with two attachments.

That is because you are calling Delete() too many times.  You are calling it
every time you encounter an individual attachment, when you should be
calling it only one time for the entire message instead.  That is a bug in
your code, not in TIdPOP3.  You need to add the following to your code to
fix it:

    for( int i = 1; i <= Form1->news; ++i )
        Form1->POP3->Retrieve( i, Form1->IdMessage1 );

        for( int j = 0; j < Form1->IdMessage1->MessageParts->Count; ++j )
            TIdAttachment *Attachment = dynamic_cast<TIdAttachment*>(
Form1->IdMessage1->MessageParts->Items[j] );
            if( Attachment )
                Form1->POP3->Delete( i );
                break; // <-- add this!!

Remy Lebeau (TeamB)



In response to

Attachments and POP3->Delete posted by duf on Thu, 25 Sep 2008