Ver Mensaje Individual
  #1  
Antiguo 22-04-2014
steelha steelha is offline
Miembro
 
Registrado: mar 2012
Posts: 158
Reputación: 13
steelha Va por buen camino
Problema con POP3 INDY

Buenas tiempo no pasaba por acá a dejar un problema . La presente es para ver si me pueden ayudar con un problema en el cual me meti por lambon (tumba polvo) "Así eso lo puedo hacer yo......" , he leeido casi todos los hilos de pop3/indy que he podido en intentado hacer un pequeño programa que lea los correos desde gmail, puede ser otro, pero este es específicamente para gmail. los correos y los que digan PAGO XXXXXX (en el subject) debería imprimir un volante para contabilidad. Biene el caso de que ya no me da error alguno pero lo único que me dice connection close gratefully algo así... pero no veo ningún correo en el meo que ando haciendo mal o que me falta. Acá dejo código

PSD: Indy 9 creo (Default Delphi 7)
Delphi 7
MSSQL (si me funciona para guardar los correos)

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdPOP3;

type
  TForm1 = class(TForm)
    IdPOP31: TIdPOP3;
    IdMessage1: TIdMessage;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   totalI : integer;
   sizetotalI : integer;
   I : integer;
   J : integer;
   K : integer;
   bodyS : TStringList;
   s : string;
   Msg: TIdMessage;
begin
     bodyS := TStringList.Create;

     IdPOP31.Host := 'pop.gmail.com';
     IdPOP31.Port := 995;
     IdPOP31.Username := 'cuentax';
     IdPOP31.Password := '*****'; // type your password (but remember, this is a security breach)
     IdPOP31.Connect;

     totalI := IdPOP31.CheckMessages;
     sizetotalI := IdPOP31.RetrieveMailBoxSize div 1024;

     ShowMessage( 'total Correos =' + ' ' + IntToStr( totalI ) );
     ShowMessage( 'Tamaño Total  =' + ' ' + IntToStr( sizetotalI ) + ' ' + 'Kilobytes' );

     memo1.Lines.Clear;
     memo1.Lines.Add(IntToStr(totalI));

     for I := 1 to totalI do
         begin
              ShowMessage( 'I =' + ' ' + IntToStr( I ) );
              Msg :=  TIdMessage.Create( Self );
              if IdPOP31.Retrieve( I, Msg ) then
                 begin
                   Msg.NoDecode := false;
                      BodyS.Clear;
                      ShowMessage( Msg.ContentType );
                      for J := 0 to Pred( Msg.MessageParts.Count) do
                          begin
                               if ( Msg.MessageParts.Items[J] is TIdAttachment ) then
                               else
                                   // begin
                                      // for K := 0 to 1 do
                                         // begin
                                                 if Msg.MessageParts.Items[J] is TIdText then
                                                    begin
                                                         Memo1.Lines.AddStrings(TIdText( Msg.MessageParts.Items[J]).Body);
                                                         BodyS.AddStrings( TIdText( Msg.MessageParts.Items[ J ]).Body );
                                                    end;
                          end;
                      ShowMessage( BodyS.Text );
                 end
              else
                  begin
                       ShowMessage( 'Internet: E-mail: Header: No se pudo cargar' );
                  end;
         end;
     IdPOP31.Disconnect;
end;

end.

Gracias de ante mano por cualquier aclaración que me pueda ayudar a encontrar una solucion
Responder Con Cita