Save sent E-mail as EML-file

Giganews Newsgroups
Subject: Save sent E-mail as EML-file
Posted by:  Stef Merlijn (merlijn-i…@xs4all.nl)
Date: Wed, 6 Feb 2008

Hello,

Can anybody tell me how I can save an E-mail as an EML-file after it is
sent by Indy?
Below you find the code that I use for composing and sending the E-mail
(thank to Gambit)

procedure TFEmailVerzenden.SendEmailMessage(HTMLBestand : string;
Attachments : TStringList);
var i : Integer;
begin
  with TIdMessageBuilderHtml.Create do
  try
    Subject := ISubject.Text;
    PlainText.Text := 'text';
    Html.LoadFromFile(HTMLBestand);
    for i := 0 to EmailFiles.Count-1 do
    begin
      If (EmailFiles.Strings[i] <> HTMLBestand) then
      begin
        HtmlFiles.Add(EmailFiles.Strings[i]);
      end;
    end;
//    Attachments.Add('c:\folder\archive.zip');
    FillMessage(MailMessage);
  finally
    Free;
  end;

  MailMessage.From.Address              := 'info@myname';
  MailMessage.From.Name                := 'My Name';
  MailMessage.Recipients.EMailAddresses := 'in…@yourname.nl';

  Mail.AuthType := satSASL;
  Mail.Username := 'in…@myname.nl';
  Mail.Password := 'xxxxxxxx';
  Mail.Host    := 'mail.myname.nl';
  Mail.Port    := 25;

  try
    Mail.Connect();
    try
      Mail.Send(MailMessage);
      showmessage('E-mail is succesfully sent!');
    except
      ShowMessage('Error ocurred while sending E-mail.');
    end;
  finally
    MailMessage.MessageParts.Clear;
    MailMessage.Headers.Clear;
    Mail.Disconnect;
  end;
end;

Replies