IdSMTPServer.OnMsgReceive event: AMsg TStream is always blank

Giganews Newsgroups
Subject: IdSMTPServer.OnMsgReceive event: AMsg TStream is always blank
Posted by:  mysticforces (paul.four…@malans.co.za)
Date: Wed, 4 Apr 2007

I'm using version 10.1.5

This is my code for the IdSMTPServer.OnMsgReceive event:

procedure TForm1.IdSMTPServer1MsgReceive(ASender: TIdSMTPServerContext;
  AMsg: TStream; var LAction: TIdDataReply);
var
  lsStr: TStringList;
begin
  lsStr := TStringList.Create;
  try
    lsStr.LoadFromStream(AMsg);
    IdMessage1.From.Address := ASender.From;
    IdMessage1.Recipients.Assign(ASender.RCPTList);
    IdMessage1.Body.AddStrings(lsStr);
    IdSMTP1.Connect;
    IdSMTP1.Send(IdMessage1);
    IdSMTP1.Disconnect;
  finally
    lsStr.Free;
  end;
  LAction := dOk;
end;

I know it's crude, so please, no comments on how I should code it better.  I'm experimenting at this stage of the project.

My point is, the AMsg variable passed through by the event doesn't have the 'message' I'm expecting.  Is there some other place to retrieve the email body?  The TStream is totally blank when I evaluated it.  Size = 0.

The message gets sent successfully, but without any subject or body.

Will 10.1.6 fix the problem?

Replies