- Recompilación en Delphi10 de todos los paquetes de RO para generar las DCU's en Lib\D10 git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@7 b6239004-a887-0f4b-9937-50029ccdca16
174 lines
5.2 KiB
ObjectPascal
174 lines
5.2 KiB
ObjectPascal
unit async_EmailSettings;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, Mask;
|
|
|
|
type
|
|
Tasync_EmailSettingsForm = class(TForm)
|
|
GroupBox1: TGroupBox;
|
|
ePOP3Host: TEdit;
|
|
Label1: TLabel;
|
|
ePOP3Port: TMaskEdit;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
ePOP3Usename: TEdit;
|
|
Label4: TLabel;
|
|
ePOP3Password: TEdit;
|
|
GroupBox2: TGroupBox;
|
|
Label5: TLabel;
|
|
Label6: TLabel;
|
|
lSMTPUserName: TLabel;
|
|
lSMTPPassword: TLabel;
|
|
eSMTPHost: TEdit;
|
|
eSMTPPort: TMaskEdit;
|
|
eSMTPUserName: TEdit;
|
|
eSMTPPassword: TEdit;
|
|
Label9: TLabel;
|
|
eServerEmail: TEdit;
|
|
lClientEmail: TLabel;
|
|
eClientEmail: TEdit;
|
|
OKButton: TButton;
|
|
CancelButton: TButton;
|
|
cbSMTPAuthentication: TCheckBox;
|
|
procedure FormShow(Sender: TObject);
|
|
procedure OKButtonClick(Sender: TObject);
|
|
procedure cbSMTPAuthenticationClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
FClientSettings: Boolean;
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
ServerEmail: string;
|
|
ClientEmail: string;
|
|
// pop3
|
|
POP3UserName: string;
|
|
Pop3Password: string;
|
|
POP3host: string;
|
|
POP3Port: integer;
|
|
// smtp
|
|
SMTPUserName: string;
|
|
SMTPPassword: string;
|
|
SMTPhost: string;
|
|
SMTPPort: integer;
|
|
SMTPAuthentication: boolean;
|
|
|
|
procedure SetupEmailSettings(AClientSettings: Boolean);
|
|
procedure LoadEmailSettings;
|
|
procedure SaveEmailSettings;
|
|
implementation
|
|
uses
|
|
IniFiles;
|
|
{$R *.dfm}
|
|
|
|
const
|
|
ini_Section = 'Global';
|
|
|
|
procedure SetupEmailSettings(AClientSettings: Boolean);
|
|
begin
|
|
with Tasync_EmailSettingsForm.Create(Application) do try
|
|
FClientSettings := AClientSettings;
|
|
ShowModal;
|
|
finally
|
|
Release;
|
|
end;
|
|
end;
|
|
|
|
procedure LoadEmailSettings;
|
|
begin
|
|
with TIniFile.Create(ChangeFileExt(Application.ExeName, '.INI')) do begin
|
|
ServerEmail := ReadString(ini_Section, 'ServerEmail', 'server@email.com');
|
|
ClientEmail := ReadString(ini_Section, 'ClientEmail', 'client@email.com');
|
|
POP3UserName := ReadString(ini_Section, 'POP3UserName', 'username');
|
|
Pop3Password := ReadString(ini_Section, 'Pop3Password', 'password');
|
|
POP3host := ReadString(ini_Section, 'POP3host', 'pop3host');
|
|
POP3Port := ReadInteger(ini_Section, 'POP3Port', 110);
|
|
SMTPAuthentication := ReadInteger(ini_Section, 'SMTPAuthentication', 0) <> 0;
|
|
if SMTPAuthentication then begin
|
|
SMTPUserName := ReadString(ini_Section, 'SMTPUserName', 'username');
|
|
SMTPPassword := ReadString(ini_Section, 'SMTPPassword', 'password');
|
|
end;
|
|
SMTPhost := ReadString(ini_Section, 'SMTPhost', 'smtphost');
|
|
SMTPPort := ReadInteger(ini_Section, 'SMTPPort', 25);
|
|
end;
|
|
end;
|
|
|
|
procedure SaveEmailSettings;
|
|
begin
|
|
with TIniFile.Create(ChangeFileExt(Application.ExeName, '.INI')) do begin
|
|
WriteString(ini_Section, 'ServerEmail', ServerEmail);
|
|
WriteString(ini_Section, 'ClientEmail', ClientEmail);
|
|
WriteString(ini_Section, 'POP3UserName', POP3UserName);
|
|
WriteString(ini_Section, 'Pop3Password', Pop3Password);
|
|
WriteString(ini_Section, 'POP3host', POP3host);
|
|
WriteInteger(ini_Section, 'POP3Port', POP3Port);
|
|
WriteInteger(ini_Section, 'SMTPAuthentication', ord(SMTPAuthentication));
|
|
if SMTPAuthentication then begin
|
|
WriteString(ini_Section, 'SMTPUserName', SMTPUserName);
|
|
WriteString(ini_Section, 'SMTPPassword', SMTPPassword);
|
|
end;
|
|
WriteString(ini_Section, 'SMTPhost', SMTPhost);
|
|
WriteInteger(ini_Section, 'SMTPPort', SMTPPort);
|
|
end;
|
|
end;
|
|
|
|
procedure Tasync_EmailSettingsForm.FormShow(Sender: TObject);
|
|
begin
|
|
eClientEmail.Visible := FClientSettings;
|
|
lClientEmail.Visible := FClientSettings;
|
|
eServerEmail.Text := ServerEmail;
|
|
eClientEmail.Text := ClientEmail;
|
|
ePOP3Host.Text := POP3host;
|
|
ePOP3Port.Text := IntToStr(POP3Port);
|
|
ePOP3Usename.Text := POP3UserName;
|
|
ePOP3Password.Text := Pop3Password;
|
|
eSMTPHost.Text := SMTPhost;
|
|
eSMTPPort.Text := IntToStr(SMTPPort);
|
|
cbSMTPAuthentication.Checked := SMTPAuthentication;
|
|
cbSMTPAuthenticationClick(cbSMTPAuthentication);
|
|
if cbSMTPAuthentication.Checked then begin
|
|
eSMTPUsername.Text := SMTPUserName;
|
|
eSMTPPassword.Text := SMTPPassword;
|
|
end
|
|
else begin
|
|
eSMTPUsername.Text := '';
|
|
eSMTPPassword.Text := '';
|
|
end;
|
|
end;
|
|
|
|
procedure Tasync_EmailSettingsForm.OKButtonClick(Sender: TObject);
|
|
begin
|
|
ServerEmail := eServerEmail.Text;
|
|
ClientEmail := eClientEmail.Text;
|
|
POP3host := ePOP3Host.Text;
|
|
POP3Port := StrToInt(Trim(ePOP3Port.Text));
|
|
POP3UserName := ePOP3Usename.Text;
|
|
Pop3Password := ePOP3Password.Text;
|
|
SMTPhost := eSMTPHost.Text;
|
|
SMTPPort := StrToInt(Trim(eSMTPPort.Text));
|
|
SMTPAuthentication := cbSMTPAuthentication.Checked;
|
|
if SMTPAuthentication then begin
|
|
SMTPUserName := eSMTPUsername.Text;
|
|
SMTPPassword := eSMTPPassword.Text;
|
|
end;
|
|
SaveEmailSettings;
|
|
end;
|
|
|
|
procedure Tasync_EmailSettingsForm.cbSMTPAuthenticationClick(Sender: TObject);
|
|
begin
|
|
with cbSMTPAuthentication do begin
|
|
eSMTPUserName.Enabled := Checked;
|
|
eSMTPPassword.Enabled := Checked;
|
|
lSMTPUserName.Enabled := Checked;
|
|
lSMTPPassword.Enabled := Checked;
|
|
end;
|
|
end;
|
|
|
|
end.
|
|
|