////////////////////////////////////////////////////////////////
//Create a dialog asking for email subject, body and signature//
////////////////////////////////////////////////////////////////
var
  i, doc, form;
  themelb, theme;
  bodylb, body;
  siglb, sig;
  okbtn;

begin
  form              := TForm.Create(nil);
  form.Caption      := 'Mail compose dialog';
  form.Position     := poScreenCenter;
  form.width        := 350;
  form.height       := 250;
                    
  themelb           := TLabel.Create(form);        
  theme             := TEdit.Create(form);
  themelb.Parent    := form;
  themelb.Left      := 10;
  themelb.Top       := 16;
  themelb.Caption   := 'Mail subject:';
  theme.Parent      := form;
  theme.Left        := 130;
  theme.Top         := 10;
  theme.Width       := 185;
  theme.Text        := '<Enter mail subject>';

  bodylb            := TLabel.Create(form);
  body              := TMemo.Create(form);
  bodylb.Parent     := form;
  bodylb.Left       := 10;
  bodylb.Top        := 35;
  bodylb.Caption    := 'Mail body:';
  body.Parent       := form;
  body.Left         := 130;
  body.Top          := 37;
  body.Lines.Add('<Enter mail body>');

  siglb             := TLabel.Create(form);
  sig               := TEdit.Create(form);
  siglb.Parent      := form;
  siglb.Left        := 10;
  siglb.Top         := 140;
  siglb.Caption     := 'Mail signature:';
  sig.Parent        := form;
  sig.Left          := 130;
  sig.Top           := 133;
  sig.Width         := 185;
  sig.Text          := '<Enter your signature>';
                  
  okbtn             := TButton.Create(form);
  okbtn.Parent      := form;
  okbtn.Left        := 160;
  okbtn.Top         := 170;
  okbtn.Caption     := 'Ok';
  okbtn.ModalResult := mrOk;

  okbtn             := TButton.Create(form);
  okbtn.Parent      := form;
  okbtn.Left        := 240;
  okbtn.Top         := 170;
  okbtn.Caption     := 'Cancel';
  okbtn.ModalResult := mrCancel;

  if form.ShowModal = mrOk then
  begin
    doc := Application.NewDocument;
    doc.Lines.Add('Mail theme: ' + theme.Text);
    doc.Lines.Add('');
    doc.Lines.Add('Hi,');
    doc.Lines.Add('');

    for i := 0 to body.Lines.Count - 1 do
      doc.Lines.Add(body.Lines.Strings[i]);

    doc.Lines.Add('');
    doc.Lines.Add('Regards, ');
    doc.Lines.Add(sig.Text + '.');
  end;

  form.Free;
end;