www.pudn.com > mail104s.lzh > MAILMAP.PAS
unit mailmap;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
TMailDataForm = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
ComboBox1: TComboBox;
Label4: TLabel;
BitBtn3: TBitBtn;
procedure FormActivate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MailDB:TStringList;
MailHandle:TextFile;
end;
var
MailDataForm: TMailDataForm;
implementation
{$R *.DFM}
procedure TMailDataForm.FormActivate(Sender: TObject);
var
I:Integer;
ListPos:Integer;
ComboStr:string;
begin
MailDB:=TStringList.Create;
ComboBox1.Items.Clear;
try
MailDB.LoadFromFile('Maildb.dat');
except
AssignFile(MailHandle,'Maildb.dat');
ReWrite(MailHandle);
CloseFile(MailHandle);
MailDB.LoadFromFile('Maildb.dat');
end;
// Put in the combobox
I:=0;
While(MailDB.Count>I) do
begin
ListPos:= Pos('/',MailDB[I]);
ComboStr:=Copy(MailDB[I],1,ListPos-1);
ComboBox1.Items.Add(ComboStr);
inc(I);
end;
end;
procedure TMailDataForm.BitBtn1Click(Sender: TObject);
var
TempStr:string;
I:Integer;
ListPos:Integer;
ComboStr:string;
begin
TempStr:=Edit1.Text+'/'+Edit2.Text+'/'+Edit3.Text;
MailDB.Add(TempStr);
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
// Put in the combobox
I:=0;
ComboBox1.Items.Clear;
While(MailDB.Count>I) do
begin
ListPos:= Pos('/',MailDB[I]);
ComboStr:=Copy(MailDB[I],1,ListPos-1);
ComboBox1.Items.Add(ComboStr);
inc(I);
end;
end;
procedure TMailDataForm.BitBtn2Click(Sender: TObject);
var
I:Integer;
ListPos:Integer;
ComboStr:string;
begin
MailDB.Delete(ComboBox1.Items.IndexOf(ComboBox1.Text));
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
// Put in the combobox
I:=0;
ComboBox1.Items.Clear;
While(MailDB.Count>I) do
begin
ListPos:= Pos('/',MailDB[I]);
ComboStr:=Copy(MailDB[I],1,ListPos-1);
ComboBox1.Items.Add(ComboStr);
inc(I);
end;
end;
procedure TMailDataForm.BitBtn3Click(Sender: TObject);
begin
MailDB.SaveToFile('MailDB.dat');
Close;
end;
procedure TMailDataForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
MailDB.Destroy;
end;
procedure TMailDataForm.ComboBox1Click(Sender: TObject);
var
I:Integer;
ResStr:string;
Pos1:integer;
begin
I:=ComboBox1.Items.IndexOf(ComboBox1.Text);
//I:=ComboBox1.Items.count-1;
ResStr:=MailDB[I];
Pos1:=Pos('/',ResStr);
Edit1.Text:=Copy(ResStr,1,Pos1-1);
ResStr:=Copy(ResStr,Pos1+1,Length(ResStr));
Pos1:=Pos('/',ResStr);
Edit2.Text:=Copy(ResStr,1,Pos1-1);
// Host name
Edit3.TExt:=Copy(ResStr,Pos1+1,Length(ResStr));
//Pos1:=Pos('/',ResStr);
//Edit3.Text:=Copy(ResStr,1,Length(ResStr));
end;
end.