Re: TIdPOP3.RetrieveRaw usage

Giganews Newsgroups
Subject: Re: TIdPOP3.RetrieveRaw usage
Posted by:  Remy Lebeau (re…@lebeausoftware.org)
Date: Wed, 26 Aug 2015

Boba wrote:

> Dear all; does below code make any sense?

TIdStream does not exist in Indy 10, so I assume you are using Indy 9 instead.
Even then, you cannot use TIdStream in this manner.  The sole purpose of
TIdStream was to add additional functionality to TStream in a time before
class helpers had been introduced into the Delphi language.  TIdStream itself
has no data storage of any kind.  For what you are attemping, use a TMemoryStream
instead:

{code}
if( IdPOP3->Connected() ){
    TMemoryStream *MStream = new TMemoryStream;
    try{
        if( IdPOP3->RetrieveRaw( 1, MStream ) ){
            MStream->Position = 0;
            IdMsg->Clear();
            IdPOP3->ProcessMessage( IdMsg, MStream, false );
            //present IdMsg to user
        }
    }
    __finally {
        delete MStream;
    }
}
{code}

> I'm trying to fugure out how to call ProcessMessage().

Why are you trying to call it directly at all?  All you are doing is duplicating
what TIdPOP3::Retrieve() already does internally for you:

{code}
if( IdPOP3->Connected() ){
    if( IdPOP3->Retrieve(1, IdMsg) ){
        //present IdMsg to user
    }
}
{code}

--
Remy Lebeau (Indy Team)

Replies

In response to

TIdPOP3.RetrieveRaw usage posted by Boba on Wed, 26 Aug 2015