Re: How to limit the Bytes on download

Giganews Newsgroups
Subject: Re: How to limit the Bytes on download
Posted by:  Remy Lebeau (TeamB) (gambit47.no.spam@no.spam.yahoo.com)
Date: Mon, 19 Jul 2004

"Mark Wergen" <m.werg…@bauer-kirch.de> wrote in message
news:Xns952B6A006CEEFmwergenbauerkirch…@209.120.248.233...

> The reason is to display a part of the body to the user
> and the user can decide to download the complete
> e-mail or not.

POP3 has the TOP command for that purpose, although it works on lines, not
bytes.  RetreiveHeader() uses TOP to request the message headers, specifying
0 as the number of lines to download from each message.  Since TIdPOP3 does
not provide native access to specify the number of lines for the TOP
command, you will have to use the SendCmd() method to issue the command
manually, ie (untested):

    // download the first 10 lines...
    IdMessage1.Clear;
    IdPop31.SendCmd('TOP ' + IntToStr(MsgNum) + ' 10', wsOk);
    IdPop31.Capture(IdMessage1.Headers, '', True);
    IdMessage1.ProcessHeaders;
    IdPop31.Capture(IdMessage1.Body);

Alternatively, you can derive a new component from TIdPOP3 and add a new
method for issuing TOP commands.  That way, you can then access the
protected ReceiveHeader() method:

    TMyIdPOP3 = class(TIdPOP3)
    public
        procedure Top(AMsgNum: Integer; ALines: Integer; AMsg, TIdMessage);
    end;

    procedure TMyIdPOP3.Top(AMsgNum: Integer; ALines: Integer; AMsg,
TIdMessage);
    begin
        AMsg.Clear;
        SendCmd('TOP ' + IntToStr(AMsgNum) + ' ' + IntToStr(ALines), wsOk);
        ReceiveHeader(AMsg);
        if ALines > 0 then Capture(AMsg.Body);
    end;

    IdPop31.Top(MsgNum, 10, IdMessage1);

Gambit

Replies

In response to

How to limit the Bytes on download posted by Mark Wergen on Mon, 19 Jul 2004