[Lazarus] help with NNTP posting
Marcus Sackrow
alb42 at web.de
Wed Nov 20 08:34:53 CET 2024
Hi,
Am 19.11.2024 um 21:25 schrieb duilio foschi via lazarus:
> I cannot understand how I can post a message into a newsgroup using INet
> components.
I am not 100% sure but as far as I remember you need to send a single
"POST" command first check the return code if you are even allowed to post
and then sent the Header and Content
> uses
> ...lNet, lclnet, lnetcomponents, LConvEncoding;
>
> var
> aStream:TMemoryStream; // correctly initialized elsewhere
> aclient:TLTCPComponent; // correctly initialized elsewhere
>
> procedure LineToStream(Buf : String);
> begin
> Buf := Buf + #13#10;
> aStream.WriteBuffer(Buf[1], Length(Buf));
> end;
>
> procedure TfrmUReader.btnSendPostClick(Sender: TObject);
> var
> a:integer;
> begin
> aStream.Clear;
> LineToStream('POST');
aStream.Position := 0;
a:=aclient.Send(aStream, aStream.Size);
if a = 340 then
begin
aStream.Clear;
> LineToStream('"peppepolpo" <octopushole at gmail.com>');
> LineToStream('Newsgroups: it.hobby.fai-da-te');
> LineToStream('Subject: test 201937');
> LineToStream('Organization: None');
> LineToStream('X-Newsreader: DIY component ');
>
> { End of header is a blank line }
> LineToStream('');
>
> { Write the message body }
> LineToStream('');
> LineToStream('test 201937');
LineToStream('.'); // End the message with a single point
>
>
> aStream.Seek(0, soFromBeginning );
>
> a:=aclient.Send(aStream, aStream.Size);
>
> // a=500 here
> end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20241120/bb38a5dd/attachment-0001.htm>
More information about the lazarus
mailing list