reading and store emails from a file

Giganews Newsgroups
Subject: reading and store emails from a file
Posted by:  Stan (an.…@sympatico.ca)
Date: Sat, 17 Jan 2004

Hi,
I'm writing an email client to read the pop3 server and store emails to a
file. The program also needs the read emails back from the file. I wonder if
there is an easy way to do it. I can do  msg.savetostream to save multiple
emails to a file, but how do I read the emails back? I tried the code below,
but it seems I always get the first email read back to Msg.  Thanks.

  vStream := TFileStream.Create('inbox.dat', fmOpenRead and
fmShareDenyWrite);
  Msg.Clear;
  vMsgClient := TIdMessageClient.Create(nil);
  vMsgClient.ProcessMessage(Msg, vStream, true);  // read the first email in
the file
  ...
  vMsgClient.ProcessMessage(Msg, vStream, true);  // read the second email
in the file

Stan

Replies