Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #14  
Antiguo 09-12-2005
elguille elguille is offline
Miembro
 
Registrado: ene 2005
Posts: 130
Poder: 22
elguille Va por buen camino
Resumo todo lo dicho con una funcion que funciona (comprobado)

añadir a USES

IdBaseComponent, IdComponent, IdTCPServer, IdSMTPServer,
IdMessage, IdEMailAddress, IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP,idexception

Código Delphi [-]
  procedure email2(host:string;nombre:string;password:string;port:integer;desde:string;
    hasta:string;asunto:string;cuerpo:string;adjunto:string);
  var
      IDSMTP1: TIDSMTP;  // Componente de envio de correo
      mensaje: TIdMessage;
  begin
  IDSMTP1:=TIDSMTP.Create(nil);
  IdSMTP1.AuthenticationType :=atLogin;
  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);//prioridad del mensaje
  CCList.EMailAddresses := '';
  BccList.EMailAddresses := '';
  TIdAttachment.Create(Mensaje.MessageParts,adjunto);
  end; //configuracion server smtp
  with idsmtp1 do
  begin
   try
      Connect;
      try
        // Envio el mensaje.
        Send(Mensaje);
      finally
        Disconnect;
      end;
  //    MessageDlg('Enviado Correctamente', mtInformation, [mbOK], 0);
    except
       // Capturo algunas excepciones que pueden ocurrir
      ON E: EIdProtocolReplyError do begin
      MessageDlg('No se ha podido enviar el email.' + #13 +
            'Incorrecto el email o el usuario o la password.', mtError, [mbOK], 0);
      end;
      on E: EFOpenError do begin
      MessageDlg('No se ha podido enviar el email.' + #13 +
            'Fichero Adjunto desconocido o erróneo.', mtError, [mbOK], 0);
      end;
      on E: EIdSocketError do begin
      MessageDlg('No se ha podido enviar el email.'+ #13 +
            'Host desconocido o incorrecto.', mtError, [mbOK], 0);
      end
      else begin
      MessageDlg('Fallo en el envio de email', mtError, [mbOK], 0);
      end;
    end;
  end;
  ENd;

Última edición por dec fecha: 09-12-2005 a las 12:31:27. Razón: ¡¡Encerrad el código fuente entre las etiquetas [DELPHI] ... [/DELPHI]!!
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 23:58:15.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi