TIdNNTP.Post wants TIdStreamVCL parameter?

Giganews Newsgroups
Subject: TIdNNTP.Post wants TIdStreamVCL parameter?
Posted by:  Jack MacRank (ja…@macrank.com)
Date: Mon, 15 Aug 2005

Hi,

First, thanks for Indy 10...it's a fantastic set of communication
components!

I'm coding an automated binary poster.  Because I want to handle the
encoding of the parts myself, I am using the Post procedure that accepts a
TStream parameter.  When I use the Post procedure with a TMemoryStream it
errors out.  I noticed in the context menu after I typed "nntp." that there
are 2 overloaded Post procedures: one accepting a TIdMessage and one
accepting a TIdStreamVCL parameter.  When I look in the TIdNNTP.pas I see
TIdMessage and TStream not TIdStreamVCL.  Is this right?

If that is right, how can I create a TFileStream, load a file into it and
copy it to the TIdStreamVCL variable?

Remy, I would really appreciate a push in the right direction on this
question.

Thanks in advance!!

procedure TfrmMain.btnPostClick(Sender: TObject);
var

  AStream: TMemoryStream;

  msg: TIdStreamVCL;

  //nested procedure
  procedure CacheLine(ALine: string);
  begin

    ALine := ALine + #13 + #10;

    msg.Write(ALine);

  end;

begin

  //loadFile := TFileStream.Create('C:\EaxCon.zip', fmOpenRead);

  AStream := TMemoryStream.Create;

  msg := TIdStreamVCL.Create(AStream);

  try

    CacheLine('From: CommandPost Test <commandpo‚Ķ@test.com>');

    CacheLine('Newsgroups: alt.binaries.test');

    CacheLine('Subject: CommandPost Test');

    CacheLine('Organization: None');

    CacheLine('X-Newsreader: CommandPost v2.00');

    CacheLine('');

    CacheLine('.');

    msg.Position := 0;

    nntp.post

    log.Lines.Add(nntp.LastCmdResult.Code);

  finally

    FreeAndNil(AStream);

    FreeAndNil(msg);

    //loadFile.Free;

  end;

end;

Replies