LoadFromStream

Giganews Newsgroups
Subject: LoadFromStream
Posted by:  Brent (te…@imppub.com)
Date: Wed, 21 Jul 2004

I'm trying to use a previously sent email as a Resend Email feature.  When I
use the idMessage.LoadFromStream nothing happens.  No properties are
populated such as To, Subject, Body or any attachments.  However,
MyTableMessage.SaveToFile('c:\temp\test.eml') works and opens just fine in
Outlook.  Any ideas?  Using the latest Delphi 7 Pro with the latest Indy 9.
Here's a portion of the code I'm using:

procedure TfrmMessageEditor.ResendBtnClick(Sender: TObject);
var
  MyStream : TStream;
begin
  if EmailLogTbl.IsEmpty then Exit; {Don't do anything if no existing
records}
  MyStream := TMemoryStream.Create; {Create Stream to transfer DBISAM
message to Indy}
  try
  EmailLogTblMessage.SaveToStream(MyStream); {BLOB field in Table}
    IdMsgSend.LoadFromStream(MyStream); {Fill Message component}
  case SmtpAuthType of {authentication settings} {from INI file}
    0: SMTP.AuthenticationType := atNone;
    1: SMTP.AuthenticationType := atLogin; {Simple Login}
  end;
  SMTP.UserName := SmtpServerUser; {General setup}
  SMTP.Password := SmtpServerPassword;
    SMTP.Host := SmtpServerName;
  SMTP.Port := SmtpServerPort;
    SMTP.Connect; {now we send the message}
  Screen.Cursor := crHourglass;
    try
    SMTP.Send(IdMsgSend);
  finally
    SMTP.Disconnect;
    Screen.Cursor := crDefault;
    MessageDlg('Message Sent.',mtInformation,[mbOK],0);
    Close;
    end;
  finally MyStream.Free; end;
end;

Thanks,
Brent

Replies