download Unit2.pas
Language: Delphi
LOC: 507
Project Info
MyMailAgent
Server: Spider_20090401_inc
Type: filesystem
...1src.zip\MyMailAgent3.1src\
   Unit1.pas
   Unit2.pas

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Spin, Buttons, ComCtrls, IniFiles, MPlayer,
  Registry;

type
  TForm2 = class(TForm)
    GroupBox1: TGroupBox;
    Servers: TComboBox;
    AddServer: TBitBtn;
    DeleteServer: TBitBtn;
    ServerName: TLabeledEdit;
    ServerHost: TLabeledEdit;
    ServerPort: TLabeledEdit;
    ServerPOP3: TRadioButton;
    ServerIMAP4: TRadioButton;
    ServerUser: TLabeledEdit;
    ServerPass: TLabeledEdit;
    GroupBox3: TGroupBox;
    Label3: TLabel;
    UseProxy: TCheckBox;
    ProxyType: TComboBox;
    ProxyHost: TLabeledEdit;
    ProxyPort: TLabeledEdit;
    ProxyUser: TLabeledEdit;
    ProxyPass: TLabeledEdit;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    Minimiz: TCheckBox;
    Autorun: TCheckBox;
    ShowTrayHints: TCheckBox;
    PlaySounds: TCheckBox;
    LoadMessageInTray: TCheckBox;
    Interval: TSpinEdit;
    Lang: TComboBox;
    GroupBox4: TGroupBox;
    Label5: TLabel;
    Icon1: TImage;
    LoadIcon1: TBitBtn;
    StandartIcon1: TBitBtn;
    Label6: TLabel;
    Icon2: TImage;
    LoadIcon2: TBitBtn;
    StandartIcon2: TBitBtn;
    Label7: TLabel;
    SoundFile: TEdit;
    PlaySound: TBitBtn;
    LoadSound: TBitBtn;
    StandartSound: TBitBtn;
    Save: TBitBtn;
    Cancel: TBitBtn;
    ServerSSL: TCheckBox;
    OpenDialog1: TOpenDialog;
    OpenDialog2: TOpenDialog;
    MediaPlayer1: TMediaPlayer;
    StopSound: TBitBtn;
    procedure FormCanResize(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Resize: Boolean);
    procedure CancelClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure UseProxyClick(Sender: TObject);
    procedure LoadIcon1Click(Sender: TObject);
    procedure LoadIcon2Click(Sender: TObject);
    procedure LoadSoundClick(Sender: TObject);
    procedure DeleteServerClick(Sender: TObject);
    procedure ServersChange(Sender: TObject);
    procedure AddServerClick(Sender: TObject);
    procedure ServersKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
    procedure LangChange(Sender: TObject);
    procedure SaveClick(Sender: TObject);
    procedure StandartIcon1Click(Sender: TObject);
    procedure StandartIcon2Click(Sender: TObject);
    procedure StandartSoundClick(Sender: TObject);
    procedure PlaySoundClick(Sender: TObject);
    procedure ServerIMAP4Click(Sender: TObject);
    procedure ServerPOP3Click(Sender: TObject);
    procedure ServerSSLClick(Sender: TObject);
    procedure StopSoundClick(Sender: TObject);
  private
  public
    procedure LoadLang(LngName:string);
    procedure LoadServer(i:longint);
    function implode(Sep:char;S:TStrings):string;
    function encode(S:String):string;
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
begin
  Resize:=false;
end;

procedure TForm2.CancelClick(Sender: TObject);
begin
  Form1.Servers.Email.Clear;
  Form1.Servers.Email.AddStrings(Form1.ServersR.Email);
  Form1.ServersR.Email.Free;
  Form1.Servers.Host.Clear;
  Form1.Servers.Host.AddStrings(Form1.ServersR.Host);
  Form1.ServersR.Host.Free;
  Form1.Servers.Port.Clear;
  Form1.Servers.Port.AddStrings(Form1.ServersR.Port);
  Form1.ServersR.Port.Free;
  Form1.Servers.SType.Clear;
  Form1.Servers.SType.AddStrings(Form1.ServersR.SType);
  Form1.ServersR.SType.Free;
  Form1.Servers.SSL.Clear;
  Form1.Servers.SSL.AddStrings(Form1.ServersR.SSL);
  Form1.ServersR.SSL.Free;
  Form1.Servers.Username.Clear;
  Form1.Servers.Username.AddStrings(Form1.ServersR.Username);
  Form1.ServersR.Username.Free;
  Form1.Servers.Password.Clear;
  Form1.Servers.Password.AddStrings(Form1.ServersR.Password);
  Form1.ServersR.Password.Free;

  Form1.LoadMailBox;
  Close;
end;

procedure TForm2.LoadLang(LngName:string);
var
  ini:TINIFile;
begin
  if(LngName<>'������� (�����������)') then begin
    ini:=TINIFile.Create(Form1.ProgDir+'Languages\'+LngName);
    //Buttons
    Save.Caption:=ini.ReadString('Form2-GroupsAndButtons','BtnSave','���������');
    Cancel.Caption:=ini.ReadString('Form2-GroupsAndButtons','BtnCancel','������');
    //Group names
    GroupBox1.Caption:=' '+ini.ReadString('Form2-GroupsAndButtons','Servers','������� �������� �����')+' ';
    GroupBox3.Caption:=' '+ini.ReadString('Form2-GroupsAndButtons','Proxy','������ ������')+' ';
    GroupBox2.Caption:=' '+ini.ReadString('Form2-GroupsAndButtons','Program','��������� ���������')+' ';
    GroupBox4.Caption:=' '+ini.ReadString('Form2-GroupsAndButtons','IconsAndSounds','������ � �����')+' ';
    //Form2-Server
    ServerName.EditLabel.Caption:=ini.ReadString('Form2-Server','Email','������ ����������� �����');
    ServerHost.EditLabel.Caption:=ini.ReadString('Form2-Server','Host','������ �������� �����');
    ServerPort.EditLabel.Caption:=ini.ReadString('Form2-Server','Port','����');
    ServerSSL.Caption:=ini.ReadString('Form2-Server','SSL','������������ ���������� ���������� (SSL)');
    ServerUser.EditLabel.Caption:=ini.ReadString('Form2-Server','Username','��� ������������');
    ServerPass.EditLabel.Caption:=ini.ReadString('Form2-Server','Password','������');
    //Form2-Proxy
    UseProxy.Caption:=ini.ReadString('Form2-Proxy','EnableProxy','������������ ������ ������');
    Label3.Caption:=ini.ReadString('Form2-Proxy','Type','���')+':';
    ProxyHost.EditLabel.Caption:=ini.ReadString('Form2-Proxy','Host','������ �������� �����');
    ProxyPort.EditLabel.Caption:=ini.ReadString('Form2-Proxy','Port','����');
    ProxyUser.EditLabel.Caption:=ini.ReadString('Form2-Proxy','Username','��� ������������');
    ProxyPass.EditLabel.Caption:=ini.ReadString('Form2-Proxy','Password','������');
    //Form2-Program
    Label4.Caption:=ini.ReadString('Form2-Program','Language','����')+':';
    Minimiz.Caption:=ini.ReadString('Form2-Program','MinimizedAtStart','�������������� ��� �������');
    Autorun.Caption:=ini.ReadString('Form2-Program','AutorunWithWindwosStart','����������� ������ � Windows');
    ShowTrayHints.Caption:=ini.ReadString('Form2-Program','ShowHints','���������� ����������� ��������� � ����');
    PlaySounds.Caption:=ini.ReadString('Form2-Program','PlaySounds','�������� �����');
    LoadMessageInTray.Caption:=ini.ReadString('Form2-Program','RetrMailIfProgramIsHide','��������� ��������� � ��������� ���������');
    Label2.Caption:=ini.ReadString('Form2-Program','CheckMsgInterval','�������� �������� ���������')+':';
    Label1.Caption:=ini.ReadString('Form2-Program','Minutes','���')+'.';
    //Form2-IconsAndSounds
    LoadIcon1.Caption:=ini.ReadString('Form2-IconsAndSounds','BtnChange','��������');
    LoadIcon2.Caption:=LoadIcon1.Caption;
    LoadSound.Caption:=LoadIcon1.Caption;
    StandartIcon1.Caption:=ini.ReadString('Form2-IconsAndSounds','BtnStandard','�����������');
    StandartIcon2.Caption:=StandartIcon1.Caption;
    StandartSound.Caption:=StandartIcon1.Caption;
    PlaySound.Caption:=ini.ReadString('Form2-IconsAndSounds','BtnPlay','�������������');
    Label5.Caption:=ini.ReadString('Form2-IconsAndSounds','YouHaveNotNewMail','��� ����� �����');
    Label6.Caption:=ini.ReadString('Form2-IconsAndSounds','YouHaveNewMail','���� ����� ������');
    Label7.Caption:=ini.ReadString('Form2-IconsAndSounds','SoundIfYouHaveNewMail','�������, ���� ���� ����� ������');
    ini.Free;
  end;
end;

procedure TForm2.FormShow(Sender: TObject);
var
  sr:TSearchRec;
begin
  if((FileExists(Form1.ProgDir+'libeay32.dll'))and(FileExists(Form1.ProgDir+'ssleay32.dll'))) then
    ServerSSL.Enabled:=true
  else
    ServerSSL.Enabled:=false;
  Form1.ServersR.Email:=TStringList.Create;
  Form1.ServersR.Email.AddStrings(Form1.Servers.Email);
  Form1.ServersR.Host:=TStringList.Create;
  Form1.ServersR.Host.AddStrings(Form1.Servers.Host);
  Form1.ServersR.Port:=TStringList.Create;
  Form1.ServersR.Port.AddStrings(Form1.Servers.Port);
  Form1.ServersR.SType:=TStringList.Create;
  Form1.ServersR.SType.AddStrings(Form1.Servers.SType);
  Form1.ServersR.SSL:=TStringList.Create;
  Form1.ServersR.SSL.AddStrings(Form1.Servers.SSL);
  Form1.ServersR.Username:=TStringList.Create;
  Form1.ServersR.Username.AddStrings(Form1.Servers.Username);
  Form1.ServersR.Password:=TStringList.Create;
  Form1.ServersR.Password.AddStrings(Form1.Servers.Password);

  //Load servers
  Servers.Clear;
  Servers.Items.Add(Form1.LngLoad('AddNewServer','����� ������'));
  Servers.Items.AddStrings(Form1.Servers.Email);
  //Load proxy
  UseProxy.Checked:=Form1.Op.UseProxy;
  ProxyType.Text:=Form1.Op.ProxyType;
  ProxyHost.Text:=Form1.Op.ProxyHost;
  ProxyPort.Text:=Form1.Op.ProxyPort;
  ProxyUser.Text:=Form1.Op.ProxyUsername;
  ProxyPass.Text:=Form1.Op.ProxyPassword;
  //Use proxy?
  label3.Enabled:=UseProxy.Checked;
  ProxyType.Enabled:=UseProxy.Checked;
  ProxyHost.Enabled:=UseProxy.Checked;
  ProxyPort.Enabled:=UseProxy.Checked;
  ProxyUser.Enabled:=UseProxy.Checked;
  ProxyPass.Enabled:=UseProxy.Checked;
  //Load languages
  Lang.Items.Clear;
  Lang.Items.Add('������� (�����������)');
  if(FindFirst(Form1.ProgDir+'Languages\*.lng',faAnyFile,sr)=0) then begin
    repeat
      if((sr.Attr and faAnyFile)=sr.Attr) then Lang.Items.Add(sr.Name);
    until FindNext(sr)<>0;
    FindClose(sr);
  end;
  //Load program settings
  Lang.Text:=Form1.Op.Lang;
  Minimiz.Checked:=Form1.Op.Minimized;
  Autorun.Checked:=Form1.Op.Autorun;
  ShowTrayHints.Checked:=Form1.Op.ShowHints;
  PlaySounds.Checked:=Form1.Op.Sounds;
  LoadMessageInTray.Checked:=Form1.Op.RetrieveIfMinimized;
  Interval.Value:=Form1.Op.Interval;

  Icon1.Picture.LoadFromFile(Form1.Op.IconNotNewMail);
  Icon2.Picture.LoadFromFile(Form1.Op.IconNewMail);

  SoundFile.Text:=Form1.Op.SoundYouHaveMail;
end;

procedure TForm2.UseProxyClick(Sender: TObject);
begin
  label3.Enabled:=UseProxy.Checked;
  ProxyType.Enabled:=UseProxy.Checked;
  ProxyHost.Enabled:=UseProxy.Checked;
  ProxyPort.Enabled:=UseProxy.Checked;
  ProxyUser.Enabled:=UseProxy.Checked;
  ProxyPass.Enabled:=UseProxy.Checked;
end;

procedure TForm2.LoadIcon1Click(Sender: TObject);
begin
  if(OpenDialog1.Execute) then begin
    Form1.Op.IconNotNewMail:=OpenDialog1.FileName;
    Icon1.Picture.LoadFromFile(Form1.Op.IconNotNewMail);
  end;
end;

procedure TForm2.LoadIcon2Click(Sender: TObject);
begin
  if(OpenDialog1.Execute) then begin
    Form1.Op.IconNewMail:=OpenDialog1.FileName;
    Icon1.Picture.LoadFromFile(Form1.Op.IconNewMail);
  end;
end;

procedure TForm2.LoadSoundClick(Sender: TObject);
begin
  if(OpenDialog2.Execute) then begin
    Form1.Op.SoundYouHaveMail:=OpenDialog2.FileName;
    SoundFile.Text:=Form1.Op.SoundYouHaveMail;
  end;
end;

procedure TForm2.LoadServer(i:longint);
begin
  ServerName.Text:='';
  ServerHost.Text:='';
  ServerPort.Text:='110';
  ServerPOP3.Checked:=true;
  ServerIMAP4.Checked:=false;
  ServerSSL.Checked:=false;
  ServerUser.Text:='';
  ServerPass.Text:='';
  if(i>=1) then begin
    dec(i);
    ServerName.Text:=Form1.Servers.Email.Strings[i];
    ServerHost.Text:=Form1.Servers.Host.Strings[i];
    ServerPort.Text:=Form1.Servers.Port.Strings[i];
    ServerPOP3.Checked:=Form1.Servers.SType.Strings[i]='0';
    ServerIMAP4.Checked:=Form1.Servers.SType.Strings[i]='1';
    ServerSSL.Checked:=Form1.Servers.SSL.Strings[i]='true';
    ServerUser.Text:=Form1.Servers.Username.Strings[i];
    ServerPass.Text:=Form1.Servers.Password.Strings[i];
  end;
end;

procedure TForm2.DeleteServerClick(Sender: TObject);
begin
  if(Servers.ItemIndex>=1) then begin
    if(MessageDlg(Form1.LngLoad('promtDeleteEmail','�� ������������� ������ ������� ���� ������?'),mtConfirmation,[mbYes,mbNo],0)=mrYes) then begin
      Form1.Servers.Email.Delete(Servers.ItemIndex-1);
      Form1.Servers.Host.Delete(Servers.ItemIndex-1);
      Form1.Servers.Port.Delete(Servers.ItemIndex-1);
      Form1.Servers.SType.Delete(Servers.ItemIndex-1);
      Form1.Servers.SSL.Delete(Servers.ItemIndex-1);
      Form1.Servers.Username.Delete(Servers.ItemIndex-1);
      Form1.Servers.Password.Delete(Servers.ItemIndex-1);
      Form1.MailBox.Items.Delete(Servers.ItemIndex);
      Servers.Items.Delete(Servers.ItemIndex);
      LoadServer(-1);
    end;
  end;
end;

procedure TForm2.ServersChange(Sender: TObject);
begin
  LoadServer(Servers.ItemIndex);
end;

procedure TForm2.AddServerClick(Sender: TObject);
var
  s:string;
  n,i:longint;
  allfields:boolean;
begin
  allfields:=(ServerName.Text<>'')and(ServerHost.Text<>'')and(ServerPort.Text<>'')and(ServerUser.Text<>'')and(ServerPass.Text<>'');
  if(allfields) then begin
    if(Servers.ItemIndex<1) then begin
      Form1.Servers.Email.Add(ServerName.Text);
      Form1.Servers.Host.Add(ServerHost.Text);
      Form1.Servers.Port.Add(ServerPort.Text);
      s:='0';
      if(ServerPOP3.Checked) then s:='0'
      else if(ServerIMAP4.Checked) then s:='1';
      Form1.Servers.SType.Add(s);
      s:='false'; if(ServerSSL.Checked) then s:='true';
      Form1.Servers.SSL.Add(s);
      Form1.Servers.Username.Add(ServerUser.Text);
      Form1.Servers.Password.Add(ServerPass.Text);
      Form1.MailBox.Items.Add(ServerName.Text);
      i:=Servers.Items.Add(ServerName.Text);
      Servers.ItemIndex:=i;
      LoadServer(i);
    end else
      if(MessageDlg(Form1.LngLoad('promtErrorExistEmail','�� ������������� ������ �������� ������������ ������?'),mtConfirmation,[mbYes,mbNo],0)=mrYes) then begin
        n:=Servers.ItemIndex-1;
        Form1.Servers.Email.Strings[n]:=ServerName.Text;
        Form1.Servers.Host.Strings[n]:=ServerHost.Text;
        Form1.Servers.Port.Strings[n]:=ServerPort.Text;
        s:='0';
        if(ServerPOP3.Checked) then s:='0'
        else if(ServerIMAP4.Checked) then s:='1';
        Form1.Servers.SType.Strings[n]:=s;
        s:='false'; if(ServerSSL.Checked) then s:='true';
        Form1.Servers.SSL.Strings[n]:=s;
        Form1.Servers.Username.Strings[n]:=ServerUser.Text;
        Form1.Servers.Password.Strings[n]:=ServerPass.Text;
        Form1.MailBox.Items.Strings[n+1]:=ServerName.Text;
        Servers.Items.Strings[n+1]:=ServerName.Text;
        Servers.ItemIndex:=n+1;
      end;
  end else
    MessageDlg(Form1.LngLoad('ErrorNotFilledForm','��������� ��� ����'),mtError,[mbOK],0);
end;

procedure TForm2.ServersKeyPress(Sender: TObject; var Key: Char);
begin
  Key:=#0;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  //Load lang
  LoadLang(Form1.Op.Lang);
end;

procedure TForm2.LangChange(Sender: TObject);
begin
  MessageDlg(Form1.LngLoad('NeedRestart','���������� ������������� ���������'),mtInformation,[mbOK],0);
end;

function TForm2.implode(Sep:char;S:TStrings):string;
var i:longint;
begin
  result:='';
  for i:=0 to S.Count-1 do
    result:=result+S.Strings[i]+Sep;
end;

const pw=#48#50#58#91#67#115#100#99#86#83#100#121#82#47;

function TForm2.encode(S:String):string;
var
  salt,saltchar,pw1:string;
  saltcharcount,i:longint;
begin
  if(length(S)>0) then begin
    for i:=1 to length(pw) do pw1:=pw1+chr(ord(pw[i]) xor i);
    //saltchar:='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
    saltchar:='';
    for i:=0 to 9 do saltchar:=saltchar+chr(i+ord('0'));
    for i:=ord('a') to ord('z') do saltchar:=saltchar+chr(i);
    for i:=ord('A') to ord('Z') do saltchar:=saltchar+chr(i);
    saltcharcount:=length(saltchar)-1;
    randomize;
    salt:=saltchar[random(saltcharcount)+1]+saltchar[random(saltcharcount)+1]+saltchar[random(saltcharcount)+1];
    form1.LbBlowfish1.GenerateKey(salt+pw);
    result:=salt+form1.LbBlowfish1.EncryptString(S);
  end else
    result:=s;
end;

procedure TForm2.SaveClick(Sender: TObject);
var
  ini:TINIFile;
  reg:tregistry;
begin
  Form1.ServersR.Email.Free;
  Form1.ServersR.Host.Free;
  Form1.ServersR.Port.Free;
  Form1.ServersR.SType.Free;
  Form1.ServersR.SSL.Free;
  Form1.ServersR.Username.Free;
  Form1.ServersR.Password.Free;

  ini:=TINIFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
  //Servers
  ini.WriteString('Servers','Email',encode(implode('|',Form1.Servers.Email)));
  ini.WriteString('Servers','Host',encode(implode('|',Form1.Servers.Host)));
  ini.WriteString('Servers','Port',encode(implode('|',Form1.Servers.Port)));
  ini.WriteString('Servers','SType',encode(implode('|',Form1.Servers.SType)));
  ini.WriteString('Servers','SSL',encode(implode('|',Form1.Servers.SSL)));
  ini.WriteString('Servers','Username',encode(implode('|',Form1.Servers.Username)));
  ini.WriteString('Servers','Password',encode(implode('|',Form1.Servers.Password)));
  //Proxy
  Form1.Op.UseProxy:=UseProxy.Checked;
  ini.WriteBool('Proxy','Enable',Form1.Op.UseProxy);
  Form1.Op.ProxyType:=ProxyType.Text;
  ini.WriteString('Proxy','Type',Form1.Op.ProxyType);
  Form1.Op.ProxyHost:=ProxyHost.Text;
  ini.WriteString('Proxy','Host',Form1.Op.ProxyHost);
  Form1.Op.ProxyPort:=ProxyPort.Text;
  ini.WriteString('Proxy','Port',Form1.Op.ProxyPort);
  Form1.Op.ProxyUsername:=ProxyUser.Text;
  ini.WriteString('Proxy','Username',Form1.Op.ProxyUsername);
  Form1.Op.ProxyPassword:=ProxyPass.Text;
  ini.WriteString('Proxy','Password',Form1.Op.ProxyPassword);
  //Program
  Form1.Op.Lang:=Lang.Text;
  ini.WriteString('Program','Language',Form1.Op.Lang);
  Form1.Op.Minimized:=Minimiz.Checked;
  ini.WriteBool('Program','Minimized',Form1.Op.Minimized);
  Form1.Op.Autorun:=Autorun.Checked;
  ini.WriteBool('Program','Autorun',Form1.Op.Autorun);
  Form1.Op.ShowHints:=ShowTrayHints.Checked;
  ini.WriteBool('Program','ShowHints',Form1.Op.ShowHints);
  Form1.Op.Sounds:=PlaySounds.Checked;
  ini.WriteBool('Program','Sounds',Form1.Op.Sounds);
  Form1.Op.RetrieveIfMinimized:=LoadMessageInTray.Checked;
  ini.WriteBool('Program','RetrieveIfMinimized',Form1.Op.RetrieveIfMinimized);
  Form1.Op.Interval:=Interval.Value;
  ini.WriteInteger('Program','Interval',Form1.Op.Interval);

  //Do Settings
  //Interval
  Form1.Timer1.Enabled:=false;
  Form1.Timer1.Interval:=Form1.Op.Interval*60000;
  Form1.Timer1.Enabled:=true;
  //Registry
  reg:=tregistry.Create;
  if(Form1.Op.Autorun) then begin
    try
      if(reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',True)) then begin
        reg.WriteString(application.Title,'"'+paramstr(0)+'"');
        reg.CloseKey;
      end;
    finally
      reg.Free;
      inherited;
    end;
  end else begin
    try
      if(reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',true)) then begin
        reg.DeleteValue(application.Title);
        reg.CloseKey;
      end;
    finally
      reg.Free;
      inherited;
    end;
  end;

  //Icons and sounds
  ini.WriteString('Program','IconNotNewMail',Form1.Op.IconNotNewMail);
  ini.WriteString('Program','IconNewMail',Form1.Op.IconNewMail);
  ini.WriteString('Program','SoundYouHaveMail',Form1.Op.SoundYouHaveMail);
  ini.Free;
  Close;
end;

procedure TForm2.StandartIcon1Click(Sender: TObject);
begin
  Form1.Op.IconNotNewMail:='Icons\notmail.ico';
  Icon1.Picture.LoadFromFile(Form1.Op.IconNotNewMail);
end;

procedure TForm2.StandartIcon2Click(Sender: TObject);
begin
  Form1.Op.IconNewMail:='Icons\mail.ico';
  Icon2.Picture.LoadFromFile(Form1.Op.IconNewMail);
end;

procedure TForm2.StandartSoundClick(Sender: TObject);
begin
  Form1.Op.SoundYouHaveMail:='Sounds\youhavemail.wav';
  SoundFile.Text:=Form1.Op.SoundYouHaveMail;
end;

procedure TForm2.PlaySoundClick(Sender: TObject);
var tmp:string;
begin
  Form1.MediaPlayer1.FileName:=SoundFile.Text;
  Form1.MediaPlayer1.Open;
  Form1.MediaPlayer1.Play;
end;

procedure TForm2.ServerIMAP4Click(Sender: TObject);
begin
  ServerPort.Text:='143';
end;

procedure TForm2.ServerPOP3Click(Sender: TObject);
begin
  if(ServerSSL.Checked) then
    ServerPort.Text:='995'
  else
    ServerPort.Text:='110';
end;

procedure TForm2.ServerSSLClick(Sender: TObject);
begin
  if(ServerSSL.Checked) then
    ServerPort.Text:='995'
  else begin
    if(ServerPOP3.Checked) then ServerPort.Text:='110'
    else
    if(ServerIMAP4.Checked) then ServerPort.Text:='143';
  end;
end;

procedure TForm2.StopSoundClick(Sender: TObject);
begin
  Form1.MediaPlayer1.Stop;
end;

end.

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us