unit Setup;

interface

uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   StdCtrls, Buttons, ComCtrls;

type
   TfmSetup = class(TForm)
    BitBtn1: TBitBtn;
    pcSetup: TPageControl;
    tsSmtp: TTabSheet;
    lbAccount: TLabel;
    lbPassword: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label10: TLabel;
    edtAccount: TEdit;
    edtPassword: TEdit;
    SMTPServer: TEdit;
    SMTPPort: TEdit;
    Email: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
   private
    { Private declarations }
   public
    { Public declarations }
   end;

var
   fmSetup: TfmSetup;

implementation

{$R *.DFM}

uses msg, inifiles;

procedure TfmSetup.FormCreate(Sender: TObject);
begin
  SMTPServer.Text := SmtpServerName;
  SMTPPort.Text := IntToStr(SmtpServerPort);
  edtAccount.Text := SmtpServerUser;
  edtPassword.Text := SmtpServerPassword;
  Email.Text := UserEmail;
end;

procedure TfmSetup.BitBtn1Click(Sender: TObject);
var
  MailIni: TIniFile;
begin
  MailIni := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Mail.ini');
  with MailIni do begin

    WriteString('Smtp', 'ServerName', SMTPServer.Text);
    SmtpServerName := SMTPServer.Text;

    WriteString('Smtp', 'ServerPort', SMTPPort.Text);
    SmtpServerPort := StrToIntDef(SMTPPort.Text, 110);

    WriteString('Smtp', 'ServerUser', edtAccount.Text);
    SmtpServerUser := edtAccount.Text;

    WriteString('Smtp', 'ServerPassword', edtPassword.Text);
    SmtpServerPassword := edtPassword.Text;

    WriteString('Email', 'PersonalEmail', Email.Text);
    UserEmail := Email.Text;



  end;
  MailIni.Free;
end;

procedure TfmSetup.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

end.

