procedure email2(host:string;nombre:string;password:string;port:integer;desde:string;hasta:string;asunto:strin g;cuerpo:string;adjunto:string);
var
IDSMTP1: TIDSMTP; mensaje: TIdMessage;
begin
screen.cursor:=crhourglass;
IDSMTP1:=TIDSMTP.Create(nil);
IdSMTP1.UserNAME := nombre;
IdSMTP1.Password := password;
IdSMTP1.Host := host;
IdSMTP1.Port := port;
MENSAJE:=TIDMESSAGE.CREATE(nil);
with Mensaje do
begin
Body.Add(CUERPO);
From.Text := desde;
Recipients.EMailAddresses := hasta;
Subject := asunto;
Priority := TIdMessagePriority(mpHighest);CCList.EMailAddresses := '';
BccList.EMailAddresses := '';
if adjunto<>'' THEN
TIdAttachmentfile.Create(Mensaje.MessageParts,adjunto);
end;
with idsmtp1 do
begin
try
Connect;
try
Send(Mensaje);
finally
Disconnect;
end;
except
on E: EFOpenError do begin
MessageDlg('No se ha podido enviar el email.' + #13 +
'Fichero Adjunto desconocido o erróneo.', mtError, [mbOK], 0);
end;
else begin
MessageDlg('Fallo en el envio de email', mtError, [mbOK], 0);
end;
end;
end;
IDSMTP1.free;
mensaje.free;
screen.cursor:=crdefault;
ENd;