发送邮件时提示:Abstract Error
时间:2011-09-24
来源:互联网
代码如下:
procedure TetPOTPO000.OnAfterApproval;
var
IEmailHost: TLoginEmailServer;
IBoby: TStringList;
IAttachmentPath: TStringList;
begin
inherited;
IBoby := TStringList.Create;
IAttachmentPath := TStringList.Create;
try
IEmailHost.SMTPHost := '192.168.16.12';
IEmailHost.SMTPPort := 25;
IEmailHost.Username := 'it-email';
IEmailHost.Password := '888898';
//IEmailHost.SmtpAuthType := 0;
IBoby.Add('PO在附件中');
IAttachmentPath.Add('..\Temp.pdf');
SendEmail(IEmailHost,'it-email','it-email2','','Test PO审核后自动发的邮件',IBoby,IAttachmentPath,'Plain');
DeleteFile('..\Temp.pdf');
finally
IBoby.Free;
IAttachmentPath.Free;
end;
调用SendEmail的代码如下:
function SendEmail(poSMTPServer:TLoginEmailServer; psFromEmial, psToEmail, CCToEmail, psSubject:string; poBody, poAttachmentPath :TStringList;
psContentType:string):Integer;
var
loIdMsgSend: TIdMessage;
loSMTP: TIdSMTP;
MailFile : TIdAttachment;
i:integer;
begin
Result:=3;
loIdMsgSend:=nil;
loSMTP:=nil;
try
loIdMsgSend:=TIdMessage.Create(nil);
loSMTP:=TIdSMTP.Create(nil);
//------邮件信息
with loIdMsgSend do
begin
ContentType := psContentType; //发送邮件的格式 'text/plain'
From.Text := psFromEmial;
ReplyTo.EMailAddresses := psFromEmial; //发件邮箱
Recipients.EMailAddresses := psToEmail; //收件邮箱
CCList.EMailAddresses := CCToEmail; //抄送邮箱
Subject := psSubject; //主题
Priority := mpHigh;
ReceiptRecipient.Text := '';
Body.Assign(poBody); //邮件内容
if Assigned(poAttachmentPath) then //附件
begin
for i := 0 to poAttachmentPath.Count-1 do
begin
MailFile := TIdAttachment.Create(loIdMsgSend.MessageParts);
MailFile.FileName := poAttachmentPath.Strings[i] ;
end;
end;
end;
//发展送
with loSMTP do
begin
AuthType := atDefault;
ReadTimeout := 10000;
Host :=poSMTPServer.SMTPHost;
Port := poSMTPServer.SMTPPort;
{if poSMTPServer.SmtpAuthType=1 then
AuthType := atLogin
else
AuthType := atNone;}
Username := poSMTPServer.Username;
Password := poSMTPServer.Password;
try
Connect;
try
Send(loIdMsgSend);//执行到这里就不成功,提示:Abstract Error。
except on E:Exception do
ShowMessage(DispString('Email send fail: ','邮件发送失败: ')+ E.Message);
end;
except
result:=2;
exit;
end;
Result:=0;
end;
finally
loIdMsgSend.Free;
loSMTP.Free;
end;
end;
本人结贴勤快,保证一周内结贴给分。
procedure TetPOTPO000.OnAfterApproval;
var
IEmailHost: TLoginEmailServer;
IBoby: TStringList;
IAttachmentPath: TStringList;
begin
inherited;
IBoby := TStringList.Create;
IAttachmentPath := TStringList.Create;
try
IEmailHost.SMTPHost := '192.168.16.12';
IEmailHost.SMTPPort := 25;
IEmailHost.Username := 'it-email';
IEmailHost.Password := '888898';
//IEmailHost.SmtpAuthType := 0;
IBoby.Add('PO在附件中');
IAttachmentPath.Add('..\Temp.pdf');
SendEmail(IEmailHost,'it-email','it-email2','','Test PO审核后自动发的邮件',IBoby,IAttachmentPath,'Plain');
DeleteFile('..\Temp.pdf');
finally
IBoby.Free;
IAttachmentPath.Free;
end;
调用SendEmail的代码如下:
function SendEmail(poSMTPServer:TLoginEmailServer; psFromEmial, psToEmail, CCToEmail, psSubject:string; poBody, poAttachmentPath :TStringList;
psContentType:string):Integer;
var
loIdMsgSend: TIdMessage;
loSMTP: TIdSMTP;
MailFile : TIdAttachment;
i:integer;
begin
Result:=3;
loIdMsgSend:=nil;
loSMTP:=nil;
try
loIdMsgSend:=TIdMessage.Create(nil);
loSMTP:=TIdSMTP.Create(nil);
//------邮件信息
with loIdMsgSend do
begin
ContentType := psContentType; //发送邮件的格式 'text/plain'
From.Text := psFromEmial;
ReplyTo.EMailAddresses := psFromEmial; //发件邮箱
Recipients.EMailAddresses := psToEmail; //收件邮箱
CCList.EMailAddresses := CCToEmail; //抄送邮箱
Subject := psSubject; //主题
Priority := mpHigh;
ReceiptRecipient.Text := '';
Body.Assign(poBody); //邮件内容
if Assigned(poAttachmentPath) then //附件
begin
for i := 0 to poAttachmentPath.Count-1 do
begin
MailFile := TIdAttachment.Create(loIdMsgSend.MessageParts);
MailFile.FileName := poAttachmentPath.Strings[i] ;
end;
end;
end;
//发展送
with loSMTP do
begin
AuthType := atDefault;
ReadTimeout := 10000;
Host :=poSMTPServer.SMTPHost;
Port := poSMTPServer.SMTPPort;
{if poSMTPServer.SmtpAuthType=1 then
AuthType := atLogin
else
AuthType := atNone;}
Username := poSMTPServer.Username;
Password := poSMTPServer.Password;
try
Connect;
try
Send(loIdMsgSend);//执行到这里就不成功,提示:Abstract Error。
except on E:Exception do
ShowMessage(DispString('Email send fail: ','邮件发送失败: ')+ E.Message);
end;
except
result:=2;
exit;
end;
Result:=0;
end;
finally
loIdMsgSend.Free;
loSMTP.Free;
end;
end;
本人结贴勤快,保证一周内结贴给分。
作者: liw125008 发布时间: 2011-09-24
抽象错误的原因是你定义了抽象方法,而没有子类实现。
或者是使用的时候,定义变量的时候,使用的时祖先类,而实现的时候也使用了祖先类。祖先类中有抽象方法。
解决方式是使用这个祖先类的子类就可以了。
或者是使用的时候,定义变量的时候,使用的时祖先类,而实现的时候也使用了祖先类。祖先类中有抽象方法。
解决方式是使用这个祖先类的子类就可以了。
作者: SmallHand 发布时间: 2011-09-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28