Wikia

Delphi Programming

TIdNNTP

2,918pages on
this wiki
Talk0

Sample code for TIdNNTP usage I scraped together from info found on the web.


IdNNTP1.Connect;
 if IdNNTP1.Connected then
 begin
   // idNNTP1.SelectGroup('borland.public.delphi.internet.winsock');
   idNNTP1.SelectGroup('alt.binaries.ftd');
   msgcount:=idnntp1.MsgCount;
   idNNTP1.GetArticle(IdNNTP1.msgHigh,idmessage1);
   for i:=0 to idmessage1.Headers.Count-1 do
     memo1.Lines.Add(idmessage1.Headers.Strings[i]);
   if not idmessage1.IsBodyEmpty then
   begin
     for i:=0 to idmessage1.Body.Count-1 do
       memo1.Lines.Add(idmessage1.Body.Strings[i]);
   end
   else
     memo1.Lines.Add ('body is empty');
 end;
 IdNNTP1.Disconnect;

some other code ...

MyResponse := TStringList.Create ;
 IdNNTP1.GetOverviewFMT(MyResponse);
 if MyResponse.Count > 0 then
    memo1.Lines.Add ( MyResponse.Text );
 MyResponse.Clear ;
 // IdNNTP1.XOVER('1-', MyResponse );
 // IdNNTP1.XOVER(IntToStr(IdNNTP1.MsgLow) + '-' + IntToStr(IdNNTP1.MsgHigh), MyResponse );
 IdNNTP1.XOVER(IntToStr(IdNNTP1.MsgHigh) + '-' + IntToStr(IdNNTP1.MsgHigh-50) , MyResponse );
 if MyResponse.Count > 0 then
 begin
   // memo1.Lines.Add ( MyResponse.Text );
   for i := 0 to MyResponse.Count - 1 do
   begin
  { procedure ParseXOVER(Aline: String; var AArticleIndex : Integer; var ASubject,
    AFrom : String; var ADate : TDateTime; var AMsgId, AReferences : String; var AByteCount,
    ALineCount : Integer; var AExtraData : String); }
     IdNNTP1.ParseXOVER(MyResponse[i],
               AArticleIndex, ASubject, AFrom,
               ADate, AMsgId, AReferences, AByteCount,
               ALineCount, AExtraData );
     memo1.Lines.Add ( 'article index : ' + inttostr(AArticleIndex) );
     memo1.Lines.Add ( 'subject       : ' + ASubject );
     memo1.Lines.Add ( 'from          : ' + AFrom );
     memo1.Lines.Add ( 'date          : ' + DateTimeToStr(ADate) );
     memo1.Lines.Add ( 'msg id        : ' + AMsgId );
     memo1.Lines.Add ( 'references    : ' + AReferences );
     memo1.Lines.Add ( 'byte count    : ' + inttostr(AByteCount) );
     memo1.Lines.Add ( 'line count    : ' + inttostr(ALineCount) );
     memo1.Lines.Add ( 'extra data    : ' + AExtraData );
   end;
 end;

See alsoEdit

Around Wikia's network

Random Wiki