在Delphi4中如何接收邮件附件(POP3)?(50分)

  • 主题发起人 MicroZeng
  • 开始时间
M

MicroZeng

Unregistered / Unconfirmed
GUEST, unregistred user!
请问:
在Delphi4中如何接收邮件附件(POP3)?
在接收邮件时:)NMPOP31.GetMailMessage(i)),附件是否一同接收过来?
若是,它以何种方式储存?怎样读取?
谢谢!
 
AttachFilePath属性指定的是保存Attach的路径,
因此附件应该是被一同接收过来并保存在这个路径下的.

文件名则在NMPOP3.mailmessage.attachments(tstringlist)
中.
 
另外:
我在接收长文件时,经常出现程序停止反应.不只何故?
附上源程序,请诊断.
其中,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;
 
NMPOP31.GetMailMessage(i);
^^^^^^^^^^^^^^^^^^^^^^^^^^
有没有在内部释放消息呢? (调用ProcessMessages)
如果有,可能就会发生重入了。
 
Chart:
我程序的ReceiveProgress是在MainForm.OnIdle事件中调用的,
它在程序有空时触发此事件.但是在调用NMPOP31.GetMailMessage(i)后
是处于循环体中, 没有ProgressMessage的调用.
变量ReceivingFile就是防止重入.
 
收到一封邮件马上把它存起来,没有
问题的,我写的系统一值没有这总错误!
 
这个问题就结束讨论把
 
我有一个问题,就是附件的问题

在Delphi4的demo中,用SMTPDemo发送的附件可以用Pop3Demo接收,
但是在附件原先的文件名前加多一个'.',不同于原先的文件名,
还多了一个文件.Temp.mme。
而我用Outlook Press发送的附件,用Pop3Demo却收不到,为什么?
为什么会收不到呢?
谢谢!
 
pop3demo里面用的nmpop3只支持一两种编码方式
所以你收不到了.
我这有个控件,你可以用用,这个控件我还没有完善,
可以先对付者用,我一有控,就会更新它的! :)

 
POP3有哪几种编码方式,我们常用的又是哪一种?
哪儿有比较全面、完善的组件下载?
谢谢
 
<a href="http://202.120.168.23">正常营业时间10:00-21:00,有时候会昼夜服务</a>
 
我连不上去呀!怎么办呢!
可以Email给我吗? thinboy@163.net
谢谢!等着你的好消息!
 
顶部