Ver Mensaje Individual
  #10  
Antiguo 22-10-2007
Avatar de jorgegetafe
jorgegetafe jorgegetafe is offline
Miembro
 
Registrado: dic 2006
Posts: 238
Reputación: 18
jorgegetafe Va por buen camino
Gracias de nuevo, ya he arreglado el fallo, no cambie una cosa que era necesario.

Ejecuto el programa y ni me muestra mensajes, ni errores ni nada, se queda trabajando y nunca acaba... :-(

Te pongo exactamente el codigo con las direcciones de correo falsas:



Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP;
type
  TForm1 = class(TForm)
    Button1: TButton;
    IdSMTP1: TIdSMTP;
    IdMessage1: TIdMessage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
  mail : TIDMessage;
  smtp : TIdSMTP;
begin
  smtp := TIdSMTP.Create(self);
  // ASIGNO EVENTOS
  smtp.Name := 'Smtp';
  // CONFIGURACION DEL SERVIDOR AL QUE SE ENVIA EL CORREO
  with smtp do begin
    AuthenticationType := atLogin;
    Host := 'smtp.gmail.com';
    port := 465;
    Username := 'pepe@gmail.com';
    Password := 'contraseña';
  end;
  mail := TIdMessage.Create(Self);
  // CONFIGURACION DEL MENSAJE A ENVIAR
  with mail do begin
    From.Address := 'pepe@gmail.com';
    Recipients.EMailAddresses := 'pepe@gmail.com';
    Subject := 'Mensaje de prueba';
    body.Text  := 'Si estás leyendo esto es porque el mensaje ha llegado correctamente';
  end;
  //aDJUNTA EL ARCHIVO
  if FileExists('C:\Documents and Settings\Jorge\Escritorio\Mandar correo/hola.txt') then        // ruta del archivo a enviar
      TIdAttachment.create(mail.MessageParts,'C:\Documents and Settings\Jorge\Escritorio\Mandar correo/hola.txt');
  try
    // CONEXION CON EL SERVIDOR DE CORREO
    smtp.Connect(10000);
    try
      // ENVIO DEL MENSAJE
      smtp.Send(mail);
    except
      on E: Exception do
         ShowMessage('Fallo al enviar: ' + E.Message);
    end;
    ShowMessage('Mensaje enviado satisfactoriamente');
  finally
    if SMTP.Connected then SMTP.Disconnect;
    smtp.free;
    mail.free;
  end;
end;
end.




Gracias una vez más.
__________________
Explicate como si fuese tonto, soy nuevo en esto de hacer programas!!!! XD
Responder Con Cita