function TServerForm.SendMail(Files: string): Boolean; //发信
begin
Result := False;
with MailMessage do begin
Clear;
subject := '文件传送';
Body.Append('这里是邮件正文');
From.Address := Trim(MailTo);
Recipients.EMailAddresses := Trim(MailTo);
end;
with MYMAILidsmtp do begin
Host := MailAddr;
Username := Trim(MailName);
PassWord := Trim(MailPass);
end;
try
TIdAttachment.Create(MailMessage.MessageParts, Files);
MYMAILidsmtp.Connect;
except
Exit;
end;
try
if (MYMAILidsmtp.AuthSchemesSupported.IndexOf('LOGIN') <> -1) then begin
MYMAILidsmtp.AuthenticationType := Atlogin;
MYMAILidsmtp.Authenticate;
end;
MYMAILidsmtp.Send(MailMessage);
finally
MYMAILidsmtp.Disconnect;
end;
end;