Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Jan : EListError - Index out of bound [0]

www.cryer.info
Managed Newsgroup Archive

EListError - Index out of bound [0]

Subject:EListError - Index out of bound [0]
Posted by:"John Mitson" (jrm..@hawaii.rr.com)
Date:Sun, 28 Jan 2007 08:51:19

I have written a simple news reader to display Newsgroups, Headers, and
Messages.  I was able to pull a list of newsgroups and headers, but ran
into an error when I attempted to display a specific message.  I
encountered a run-time error on following line:

Memo1.Lines.Text := TIdText(IdMessage1.MessageParts.Items[0]).Body.Text;

Raised an exception - ElistError with messageList Index Out of Bounds [0]

Any help is greatly appreciated.

John

Here is the complete program:

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
   Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient,
   IdExplicitTLSClientServerBase, IdMessageClient, IdNNTP, IdMessage,
IdText;

type
   TForm1 = class(TForm)
     ngListBtn: TButton;
     IdNNTP1: TIdNNTP;
     ngListMemo: TMemo;
     ngSelectGroupBtn: TButton;
     ngGroupMemo: TMemo;
     IdMessage1: TIdMessage;
     Button1: TButton;
     Memo1: TMemo;
     procedure ngListBtnClick(Sender: TObject);
     procedure ngSelectGroupBtnClick(Sender: TObject);
     procedure Button1Click(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
   IdNNTP1.GetArticle(74716,IdMessage1);
   Memo1.Lines.Text := TIdText(IdMessage1.MessageParts.Items[0]).Body.Text;
end;

procedure TForm1.ngListBtnClick(Sender: TObject);
begin
   IdNNTP1.Host := 'forums.borland.com';
   IdNNTP1.Port := 119;
   IdNNTP1.Connect;
   IdNNTP1.GetNewsgroupList(ngListMemo.Lines);
end;

procedure TForm1.ngSelectGroupBtnClick(Sender: TObject);
begin
   IdNNTP1.SelectGroup('borland.public.delphi.graphics');
   IdNNTP1.XOVER('73414-74716',ngGroupMemo.Lines);
end;

end.

Replies:

www.cryer.info
Managed Newsgroup Archive