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" <[email protected]>');
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;
--
_______________________________________________
lazarus mailing list
[email protected]
https://lists.lazarus-ide.org/listinfo/lazarus