Board index » delphi » idnntp questions/advice - Delphi 7 indy 10.1.15

idnntp questions/advice - Delphi 7 indy 10.1.15


2006-04-06 06:46:28 PM
delphi99
I hope someone can help me with this. I am basically trying to create a
newsgroup reader app. But i cannot find any examples of how to use idnntp
component. What i want to do is this:
I've already worked out(with help from this newsgroup) how to download ALL
the articles in a particular newsgroup, as the code below demonstrates:
var
msgnum:integer;
...
IdNNTP1.Host := 'newsgroups.borland.com';
IdNNTP1.Connect;
IdNNTP1.SelectGroup('borland.public.delphi.internet.winsock');
for MsgNum := IdNNTP1.MsgLow to IdNNTP1.MsgHigh do
begin
if IdNNTP1.GetHeader(MsgNum, IdMessage1) then
application.ProcessMessages;
li:=list.Items.Add;
li.Caption:=inttostr(msgnum);
li.SubItems.add(idmessage1.Subject);
li.SubItems.add(IdMessage1.From.Name);
end;
........................
Because there are like zillions of messages in this group, I'd like to
download only the first 50 or so messages. How would i go about doing this?
I cannot understand the IdNNTP1.MsgHigh and 'IdNNTP1.MsgLow' properties,
what exactly do they represent in the above code?
2. Once I have downloaded the 50 messages, i want to read a specific message
say MsgNo 796, how would i go about doing this? Below is some code i've
tried to use for this purpose, unsuccessfully:
var
msgno:integer;
.....................
IdNNTP1.Host := 'newsgroups.borland.com';
if not idnntp1.Connected then idnntp1.Connect;
IdNNTP1.SelectGroup('borland.public.delphi.internet.winsock');
IdNNTP1.GetBody(msgno,idmessage1);
memo1.Lines.Add(idmessage1.Body.Text);
...........
When i run this code, it just freezes.
3. I'd like to be able to reply to whatever msg I am reading. Can someone
help with this?
Thanks
 
 

Re:idnntp questions/advice - Delphi 7 indy 10.1.15

"Jacques Noah" <XXXX@XXXXX.COM>writes
Quote
Because there are like zillions of messages in this group, i would
like to download only the first 50 or so messages. How would i
go about doing this?
Simply limit your loop to the first 50 in the range of numbers. You already
have the smallest and largest numbers, so simply add 50 to the smallest and
make sure it desn't exceed the largest.
Quote
I cannot understand the IdNNTP1.MsgHigh and 'IdNNTP1.MsgLow' properties
I suggest you read RFCs 977 (www.ietf.org/rfc/rfc0977.txt) and 2980
(www.ietf.org/rfc/rfc2980.txt) for the specific details about how the
NNTP protocol works in general.
Quote
what exactly do they represent in the above code?
The smallest and largest article numbers that are available in the group.
Every message has its own number in the list. In order to retreive a
specific message, you have to know its number in the group.
Quote
Once I have downloaded the 50 messages, i want to read a specific message
say MsgNo 796, how would i go about doing this?
Simply pass 796 to one of the Get...() methods (GetArticle, GetHeader,
GetBody) that is overloaded with an AMsgNo parameter.
Quote
Below is some code I have tried to use for this purpose, unsuccessfully:
<snip>
When i run this code, it just freezes.
At which point exactly? Please be more specific.
Quote
I would like to be able to reply to whatever msg I am reading.
You will have to populate a TIdMessage with the desired values, and then
send it to the server via the Post() method. The newsgroup has to allow
posting or an error will be raised. And make sure that you are fill in the
'References' header of the reply message so that other readers can know
which message(s) are being replied to, so that your reply message can be
displayed to their users in the proper hierarchical manner.
Gambit
 

Re:idnntp questions/advice - Delphi 7 indy 10.1.15

"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote
And make sure that you are fill in the 'References' header of the
reply message so that other readers can know which message(s)
are being replied to, so that your reply message can be displayed
to their users in the proper hierarchical manner.
In other words, when replying to a particular message, take that message's
existing 'References' header, append that message's MessageID to the end of
the list, and then use the final list in your reply message's 'References'
header.
Gambit