Ver Mensaje Individual
  #12  
Antiguo 09-03-2016
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.038
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Bienvenido a clubdelphi, como siempre aconsejamos a los nuevos, no olvides leer nuestra guía de estilo, gracias por tu colaboración
Has incumplido un montón de normas de los foros, es normal, no lo sabías, por eso te indico que leas nuestra guía de estilo
Y después crea un hilo nuevo con tu duda, le pones un título descriptivo y explicas lo más detalladamente tu problema.

Y recuerda poner los tags al código fuente, ejemplo:



Gracias


Cita:
Empezado por superfile Ver Mensaje
ESTOY TRATANDO DE ENVIAR UN ARCHIVO POR CORREO CON DELPHI XE2 CON EL SIGUIENTE CODIGO Y ME GENERA UN ERROR
must issue a starttls command first
uses IdAttachmentFile;
procedure EnviarMensaje( sUsuario, sClave, sHost, sAdjunto, sAsunto, sDestino, sMensaje: String );
var
SMTP: TIdSMTP;
Mensaje: TIdMessage;
Adjunto: TIdAttachmentFile; //declaracion de la nueva variable
begin
SMTP := TIdSMTP.Create( nil );
SMTP.Username := sUsuario;
SMTP.Password := sClave;
SMTP.Host := sHost;
SMTP.Port := 587;//25;
//SMTP.AuthenticationType := atLogin;--indy9
SMTP.AuthType := satDefault;
// SMTP.AuthType := atlogin;
Mensaje := TIdMessage.Create( nil );
Mensaje.Clear;
Mensaje.From.Name := sDestino;
Mensaje.From.Address := sDestino;
Mensaje.Subject := sAsunto;
Mensaje.Body.Text := sMensaje;
Mensaje.Recipients.Add;
Mensaje.Recipients.Items[0].Address := sDestino;
if sAdjunto <> '' then
begin
if FileExists( sAdjunto ) then
// Adjunto := TIdAttachment.Create( Mensaje.MessageParts, sAdjunto ); --indy9
Adjunto := TIdAttachmentFile.Create( Mensaje.MessageParts, sAdjunto );
end
else
Adjunto := nil;
try
SMTP.Connect;
except
raise Exception.Create( 'Error al conectar con el servidor.' );
end;
if SMTP.Connected then
begin
try
SMTP.Send( Mensaje );
except
raise Exception.Create( 'Error al enviar el mensaje.' );
end;
try
SMTP.Disconnect;
except
raise Exception.Create( 'Error al desconectar del servidor.' );
end;
end;
if Adjunto <> nil then
FreeAndNil( Adjunto );
FreeAndNil( Mensaje );
FreeAndNil( SMTP );
Application.MessageBox( 'Mensaje enviado correctamente.',
'Fin de proceso',MB_ICONINFORMATION );
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
EnviarMensaje( 'file_iscomop@hotmail.com', 'corazon12', 'smtp.live.com',
'C:\Temp\CFDI26.xml', 'Te envio mi documento',
'file_iscomp@hotmail.com', 'Adjunto archivo: factura' );
end;
Responder Con Cita