一个indy控件的问题。。。(100分)

X

xhli

Unregistered / Unconfirmed
GUEST, unregistred user!
我安装啦indy,好像是9.0
我在delphi5下写啦段代码:(加入啦一个TidMessage和一个TidSMTP控件)
SMTP.AuthenticationType := atLogin;
SMTP.Username:= 'xxx@263.net';//帐户
SMTP.Password :='xxx' ;//密码
SMTP.Host := 'SMTP.263.net';
SMTP.Port := 25;
{now we send the message}
try
SMTP.Connect;
except
showmessage('连接失败!');
exit;
end;
try
with IdMsgSend do
begin
body.Clear;
Body.Add('test');//内容
From.Text := 'xxx@263.net';
Recipients.EMailAddresses :='yyy@163.net';//收件人
Subject:='test';//主题
end;
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
怎么一运行就死啦?只有这些代码!
 
上面的问题已经解决啦!但我怎么能得到发送失败或成功的消息呢?
我用
try
SMTP.Send(IdMsgSend);
except
showmessage('发送失败');
end;
没有用,SMTP.Send(IdMsgSend)是不是有返回值得?该怎么办?????

 
哪位知道帮帮嘛?怎么捕捉错误信息啊????
 
写一个过程
procedure DoException(Sender: TObject; E: Exception);
begin
//在这里进行错误处理
end;
然后
procedure TfmMain.FormCreate(Sender: TObject);
begin
//可以截获大部分的程序异常信息
Application.OnException := DoException;
end;

 
在DoException中也还不是得不到错误信息啊!比如发送失败,你怎么知道?
 
怎么这么冷清?。。。。。
 
试试这样行不行
aa:= 0;
try
StatusBar1.SimpleText := '正在发送邮件...';
Send(idMSend);
aa := 1;
StatusBar1.SimpleText := '发送成功!';
finally
if aa = 0 then
StatusBar1.SimpleText := '发送失败!';
DisConnect;
end;

 
不行的,因为SMTP.Send(IdMsgSend);这一步不管你发没发出去,她都继续执行下一步!
真是头痛,indy这个控件还都得啦奖的,怎么这么难处理?哪位相告。。。。。。
 
她都把原来smtp控件的onsuccess和onfailure事件搞哪去啦?
 
看来这个问题比较难!
 
谢谢sun77wind的回答,
不过我想啦一下,觉得自己有点多此一举啦,邮件发送,只要连上
服务器,通过验证就可以啦,登陆263发邮件也是一样,即使乱输一个收件人地址,当时
也会说邮件已发送,只是后来会被打回来,所以我觉得可以不考虑这个因数,所以我结束
我的贴子
 
顶部