есть код:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, StrUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
StdCtrls, IdAntiFreezeBase, IdAntiFreeze, Mask, IdMessageClient,
IdPOP3, IdMessage, ComCtrls, Math;
type
TForm1 = class(TForm)
IdAntiFreeze1: TIdAntiFreeze;
pop3: TIdPOP3;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
server: TEdit;
login: TEdit;
passw: TMaskEdit;
Button1: TButton;
idm: TIdMessage;
GroupBox2: TGroupBox;
Label4: TLabel;
allmsgcount: TLabel;
Label6: TLabel;
allmsgsize: TLabel;
Label5: TLabel;
restmsgcount: TLabel;
Label8: TLabel;
restmsgsize: TLabel;
ProgressBar1: TProgressBar;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,msgs,msgss:Integer;
var at:TIdAttachment;
begin
pop3.Host := server.Text;
pop3.UserId := login.Text;
pop3.Password := passw.Text;
try
pop3.Connect;
except
ShowMessage('Невозможно подключиться к серверу!');
exit;
end;
Button1.Enabled := false;
if not pop3.CheckMessages > 0 then
begin
ShowMessage('В вашем ящике нет сообщений!');
exit;
end;
msgs := pop3.CheckMessages;
msgss := pop3.RetrieveMailBoxSize;
allmsgcount.Caption := IntToStr(msgs);
allmsgsize.Caption := convsize(msgss);
restmsgcount.Caption := IntToStr(msgs);
allmsgsize.Caption := convsize(msgss);
ProgressBar1.Max := msgss;
ProgressBar1.Min := 0;
Button2.Enabled := true;
for i:=1 to msgs do
begin
pop3.Retrieve(i,idm);
at := TIdAttachment.Create(idm.MessageParts);
at.SaveToFile(AnsiReplaceStr(at.FileName,'"',''));
at.Free;
ProgressBar1.StepBy(pop3.RetrieveMsgSize(i));
msgs := msgs-1;
msgss := msgss-pop3.RetrieveMsgSize(i);
restmsgcount.Caption := IntToStr(msgs);
restmsgsize.Caption := convsize(msgss);
end;
pop3.Disconnect;
Button2.Enabled := false;
Button1.Enabled := True;
end;
end.
судя по мануалу дельфи, выделенный фрагмент должен сохранять аттачмент из сообщения в файл, но этого не происходит.. прога никаких ошибок не выдает.. в чем здесь проблема?
Социальные закладки