Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Colaboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-11-2016
Tecnofacil Tecnofacil is offline
Miembro
 
Registrado: jun 2015
Posts: 50
Poder: 11
Tecnofacil Va por buen camino
Prueba con esto, a mi me funciono hace unos días aun.
Código Delphi [-]
procedure Tfpdfemail.btn_emailClick(Sender: TObject);
  // variables y objetos necesarios para el envío
  Var
    IdSSLIOHandlerSocket: TIdSSLIOHandlerSocketOpenSSL;
    IdSMTP: TIdSMTP;
    IdMessage: TIdMessage;
    IdText: TIdText;
    sAnexo, ruta: string;
begin
    // -- ENVIO POR CORREO --
   // instanciación de objetos
  IdSSLIOHandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
   IdSMTP := TIdSMTP.Create(Self);
  IdMessage := TIdMessage.Create(Self);
   try
    // Configuración de protocolo SSL (TIdSSLIOHandlerSocketOpenSSL)
    IdSSLIOHandlerSocket.SSLOptions.Method := sslvSSLv23;
    IdSSLIOHandlerSocket.SSLOptions.Mode := sslmClient;
     // Configuración de servidor SMTP (TIdSMTP)

    // -- PARA GOOGLE --
       IdSMTP.IOHandler := IdSSLIOHandlerSocket;
       IdSMTP.UseTLS := utUseImplicitTLS;
       IdSMTP.AuthType := satDefault;
       IdSMTP.Port := 465;
       IdSMTP.Host := 'smtp.gmail.com';
       IdSMTP.Username := '[email protected]';
       IdSMTP.Password := 'password';

     // Configuración del mensage (TIdMessage)
    IdMessage.From.Address := 'micorreo@dominio';
    IdMessage.From.Name := 'Mi Nombre';
    IdMessage.ReplyTo.EMailAddresses := IdMessage.From.Address;
    IdMessage.Recipients.Add.Text := 'destinatario1@dominio';
    IdMessage.Recipients.Add.Text := 'destinatario2@dominio';
    IdMessage.Recipients.Add.Text := 'destinatario3@dominio';
    //Se pueden agregar todas las cuentas de destino que se necesite
    IdMessage.Subject := 'Correo automático del Sistema';
    IdMessage.Encoding := meMIME;
    // Configuración del cuerpo de email (TIdText)
    IdText := TIdText.Create(IdMessage.MessageParts);
    IdText.Body.Add('No responda a este correo, se envía automáticamente desde el sistema.');
    IdText.Body.Add('Se adjunta pdf.');
    IdText.ContentType := 'text/plain; charset=iso-8859-1';
     // Opcional - Adjunto (TIdAttachmentFile)
    sAnexo := 'C:\pdf\Algo.pdf';
    if FileExists(sAnexo) then
    begin
      TIdAttachmentFile.Create(IdMessage.MessageParts, sAnexo);
    end;
     // Conexión y autenticación
    try
      IdSMTP.Connect;
      IdSMTP.Authenticate;
    except
      on E:Exception do
      begin
        MessageDlg('Error en la conexión o autenticación: ' +
          E.Message, mtWarning, [mbOK], 0);
        Exit;
      end;
    end;
     // Envio
    try
      IdSMTP.Send(IdMessage);
      MessageDlg('Correo enviado correctamente!', mtInformation, [mbOK], 0);
    except
      On E:Exception do
      begin
        MessageDlg('Error al enviar el correo: ' +
          E.Message, mtWarning, [mbOK], 0);
      end;
    end;
  finally
    // desconectar del servidor
    IdSMTP.Disconnect;
    // liberación de las DLL
    UnLoadOpenSSLLibrary;
    // liberación de objetos
    FreeAndNil(IdMessage);
    FreeAndNil(IdSSLIOHandlerSocket);
    FreeAndNil(IdSMTP);
  end;
end;
Responder Con Cita
  #2  
Antiguo 25-01-2017
paul170185 paul170185 is offline
Miembro
 
Registrado: mar 2008
Posts: 24
Poder: 0
paul170185 Va por buen camino
Question

Hola que tal, he visto el código para envió, funciona correctamente, pero para recibir?, yo necesito recibir correos con archivos adjuntos pero no me desconecta y aparece el mismo error, alguien tiene algun ejemplo?
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
delphi imap gmail obtener mails no leidos, mas recientes, por fecha JXJ Varios 1 05-02-2014 04:51:50
Sobre error para enviar email por gmail lduron Varios 8 23-11-2011 00:19:31
Imap de indy + gmail Enan0 Internet 0 10-02-2010 08:35:02
Imap LiAnTe- Varios 1 03-01-2008 22:02:17
Problemas con IMAP albertoP PHP 1 15-10-2006 00:06:15


La franja horaria es GMT +2. Ahora son las 15:35: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