unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    B1: TBitBtn;
    Memo1: TMemo;
    NMSMTP1: TNMSMTP;
    Label1: TLabel;
    procedure B1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.B1Click(Sender: TObject);
label a,l2;
var
address,name,s,stmp:string;
f: textfile;
i:integer;
begin
if FileExists('list.txt')=false then goto a;
NMSMTP1.Connect;
NMSMTP1.PostMessage.FromAddress :='aiv@aiv.i-connect.com';
NMSMTP1.PostMessage.FromName :='AIV';
NMSMTP1.PostMessage.Subject :='AIV-TESTs for Certified Professionals of Information Technology';

AssignFile(f,'list.txt');
Reset(f);
while not eof(f)do begin
readln(f,s);
stmp:='';
for i:=1 to 100 do
begin
if s[i]<>' ' then  stmp:=stmp+s[i] else  goto l2;
end;
l2:;
address:=stmp;
name:=copy(s,35,60);
name:='Dear '+name;
Memo1.Lines[0]:=name;

NMSMTP1.PostMessage.ToAddress.Add(address);
NMSMTP1.PostMessage.Body.Assign(Memo1.Lines);
NMSMTP1.SendMail;
label1.Caption:=address;
end;
CloseFile(f);
a:;
label1.Caption:=' F I N I S H ! ';
end;

end.
