Hola volare!
El Mensaje se configura de la siguiente manera:
Código:
with idMessage do begin
// Cuerpo del mensaje.
Body.Clear;
Body.Add('Aqui añades el cuerpo del mensaje);
// Cuenta Origen.
From.Text := EMAILORIGEN;
// Cuenta Destino.
Recipients.EMailAddresses := EMAILDESTINO;
// Asunto del email.
Subject := ASUNTO;
// Prioridad del mensaje, ALTA.
Priority := TidMessagePriority(mpHighest);
// Coloco el archivo adjunto el cual enviar.
TidAttachment.Create(idMensage.MessageParts,ARCHIVOADJUNTO);
end;
Y el idSMPT :
Código:
with idSMPT do begin
// Configuro autentificación.
AuthenticationType := atLogin;
Username := USERNAME; // Nombre del usuario
Password := PASS; // la password
// Configuro el servidor SMTP.
Host := HOST;
Port := PUERTO;
try
Connect;
try
// Envio el mensaje.
Send(idMenssage);
finally
Disconnect;
end;
Msg('Enviado Correctamente');
except
// Capturo algunas excepciones que pueden ocurrir
ON E: EIdProtocolReplyError do begin
Msg('No se ha podido enviar el email.' + #13 +
'Incorrecto el email o el usuario o la password.');
end;
on E: EFOpenError do begin
Msg('No se ha podido enviar el email.' + #13 +
'Fichero Adjunto desconocido o erróneo.');
end;
on E: EIdSocketError do begin
Msg('No se ha podido enviar el email.'+ #13 +
'Host desconocido o incorrecto.');
end
else begin
Msg('Fallo en el envio de email');
end;
end;
if connected then Disconnect;
end
Espero que te sirva.
Salu2!