Entwickler-Ecke

Internet / Netzwerk - IdSMTPServer - ReceiveRaw -> VStream speichern...


FriFra - Do 03.07.03 11:19
Titel: IdSMTPServer - ReceiveRaw -> VStream speichern...
Ich hab mich bisher noch nicht so recht mit der SMTP-Server Komponente befasst. Mein Code liefert zwar in der Regel Dateien von der Grösse der Mails, diese sind aber leer und wenn ein Anhang dabei war ist die Grösse 0...


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.IdSMTPServer1ReceiveRaw(ASender: TIdCommand;
  var VStream: TStream; RCPT: TIdEMailAddressList;
  var CustomError: string);
var
  FS: TFileStream;
begin
  // This is the main event for receiving the message itself if you are using
  // the ReceiveRAW method
  // The message data will be given to you in VSTREAM
  // Capture it using a memorystream, filestream, or whatever type of stream
  // is suitable to your storage mechanism.
  // The RCPT variable is a list of recipients for the message
  FS := TFileStream.Create('Out_' + RCPT.EMailAddresses + '_' +
    FormatDateTime('mmddyyyy_hhnnss', now) + '.txt', fmCreate);
  FS.Write(VStream, VStream.Size);
  FS.Free;
end;