Ver Mensaje Individual
  #1  
Antiguo 21-11-2013
Taburiente Taburiente is offline
Miembro
 
Registrado: may 2006
Posts: 26
Reputación: 0
Taburiente Va por buen camino
Problema envió correo

Hola a todos,

A ver si me podéis echar una mano,tengo una aplicación que lo que hace entre otras cosas es enviar un fichero a una dirección de correo y que funcionaba correctamente hasta que telefónica me cambio el servido smtp y el pueto a 587 con seguridad TLS, y desde entonces obtengo erro 5.7.1, mi codigo es el siguiente

Cita:
function TfrmHistorico.EnviarAlbaran(const sFichAlbaran: string): boolean;
var
ServidorSMTP: TIdSMTP;
MailMessage: TIdMessage;
Attachment: TIdAttachment;

begin
Result := FALSE;

if FileExists(sFichAlbaran) then
begin
ServidorSmtp := TIdSMTP.Create(Self);

MailMessage := TIdMessage.Create(Self);
with MailMessage do
begin
Subject := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'ASUNTO', '');
//
Body.Clear;
Body.Add('Albarán: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE1', 'ALBARAN', ''));
Body.Add('Fecha: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE1', 'FECHA', ''));
Body.Add('Usuario: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE4', 'USR_OID', ''));
Body.Add('Nombre: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE4', 'USR_NOMBRE', ''));
//
From.Address := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'REMITENTE', '');
From.Name := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SEUDONIMO', '');
//
Recipients.EMailAddresses := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'DESTINATARIO', '');
end;

Attachment := TIdAttachment.Create(MailMessage.MessageParts, sFichAlbaran);

ServidorSMTP.Host := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_SMTP', '');
ServidorSMTP.Port := StrToIntDef(LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_PUERTO', '587'), 587);
ServidorSMTP.AuthenticationType:= atLogin;

// Datos de la cuenta de usuario
ServidorSMTP.Username:= 'albaranes@xxxx.e.telefonica.net'; // LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_USUARIO', '');

servidorSMTP.Password:= '111111'; // LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_CONTRASENA', '');
try
servidorSMTP.Connect(10000);

try
servidorSMTP.Send(MailMessage);

Result := TRUE;

except on E: Exception do
ShowMessage('ERROR al enviar albarán...'+#13+#13+E.Message);
end;

finally
servidorSMTP.Disconnect;
Attachment.Free;
MailMessage.Free;
servidorSMTP.Free;
end;

end
else
raise Exception.Create('ERROR no encuentro el fichero de albarán...'+sFichAlbaran);
end;
y en el fichero ini, lo siguiente

Cita:
SERVIDOR_SMTP=smtp.office365.com
SERVIDOR_PUERTO=587
SERVIDOR_USUARIO=albaranes@xxxx.e.telefonica.net
SERVIDOR_CONTRASENA=111111
El programa esta hecho con Delphi 7 y la versión de Indy es la 9

Agradecería cualquier ayuda.

Un saludo
Responder Con Cita