带附件
procedure SendMail;
const ErrJpg ='ErrJpg.jpg';
var
FileName :string;
p :TLoginEmailServer;
f :TStrings;
fromEmail,toEmail,ccListEmail,Subject :String;
i :Integer;
begin
FileName :=GetAppPath + ErrJpg;
if FileExists(FileName) then DeleteFile(FileName);
try
CapFullScreen(FileName);
Subject :='错误信息';
with p do
begin
SMTPHost :='*.*.com.cn';
SMTPPort :=25;
Username :='*@*.com.cn';
Password :='****';
SmtpAuthType :=1;
end;
f :=TStringList.Create;
try
f.Add(FileName);
fromEmail :='*@*.com.cn';
toEmail :='*@*.com.cn';
ccListEmail :='';
Subject :='错误信息';
i :=SendEmail(p,Memo1.Lines,fromEmail,toEmail,Subject,'',ccListEmail,f);
if i<>0 then MessageBox(Handle,'邮件发送失败!','错误',MB_OK +MB_ICONERROR)
else MessageBox(Handle,'邮件发送成功!','提示',MB_OK +MB_ICONINFORMATION);
finally
FreeAndNil(f);
end;
finally
if FileExists(FileName) then DeleteFile(FileName);
end;