另外:
我在接收长文件时,经常出现程序停止反应.不只何故?
附上源程序,请诊断.
其中,ReceiveProgress事件在MailForm的OnIdle
事件中调用. ReceivingFile 和 ReceiveStage是全局变量.
在"接收"按钮OnClick事件中: ReceiveStage := 0;
谢谢.
procedure TReceiveFileForm.ReceiveProgress;
var i : Integer;
begin
if ReceivingFile then Exit;
case ReceiveStage of
0:
begin
ReceivingFile := True;
ReceiveFileForm.Show;
with NMPOP31 do
begin
AttachFilePath := 'C:/temp';
DeleteOnRead := FALSE;
ReportLevel := 2;
//TimeOut := 60000;
Host := MainIniFile.ReadString('MailSetting','Host', '');
Port := StrToInt(MainIniFile.ReadString
('MailSetting', 'InPort', ''));
UserID := MainIniFile.ReadString('MailSetting','UserID', '');
Password := MainIniFile.ReadString('MailSetting',
'Password', '');
if not Connected then Connect;
end;
Inc(ReceiveStage);
ReceivingFile := False;
end;
1:
begin
try
ReceivingFile := True;
Screen.Cursor := crHourGlass;
for i:= 1 to NMPOP31.MailCount do
begin
NMPOP31.GetMailMessage(i);
with DirEMForm.MailQuery do
begin
if not DirEMForm.Query1.CanModify then
with DirEMForm.MailQuery do
begin
DisableControls;
Active := False;
SQL.Clear;
SQL.Add('Select * from Mail');
Open;
EnableControls;
end;
Append;
FieldByName('To').AsString := NMPOP31.MailMessage.From;
FieldByName('Sub').AsString := MPOP31.MailMessage.Subject;
FieldByName('MTime').AsString := FormatDateTime('yy-mm-dd
hh:mm', now);
FieldByName('MType').AsString := '已收';
DirEmForm.DBEditor.Lines.Assign(NMPOP31.MailMessage.Body);
Post;
end;
end;{end of Receive File}
finally
Screen.Cursor := crDefault;
Inc(ReceiveStage);
ReceivingFile := False;
end;
end;
2:
begin
ReceiveFileForm.Close;
Inc(ReceiveStage);
end;
else end;
end;