Ver Mensaje Individual
  #3  
Antiguo 12-07-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Esto no me va mal en Delphi 7 con Indy 9.

Código Delphi [-]
uses
   IdSMTP, IdMessage;
   
 procedure TForm1.Button1Click(Sender: TObject);
 var
   smtp: TIdSMTP;
   mail: TIdMessage;
 begin
   smtp := TIdSMTP.Create(Self);
   mail := TIdMessage.Create(Self);
   
   with smtp do
   begin
     Port := 25;
     Host := 'smtp.servidorcorreo.es';
     Username := '';
     Password := '';
   end;
   
   with mail do
   begin
     Recipients.Add;
     Recipients[0].Name := 'destinatario';
     Recipients[0].Address := 'correo@destinatario.com';
     From.Name := 'remitente';
     From.Address := 'correo@remitente.com';
     Subject := 'Asunto del correo';
     Body.Text := 'Cuerpo del correo';
   end;
   
   TIdAttachment.Create(mail.MessageParts, 'C:\adjunto.txt');
   
   smtp.Connect(30000);
   try
     try
       smtp.Send(mail);
     except
       on E: Exception do
         ShowMessage(E.Message);
     end;
   finally
     if smtp.Connected then
       smtp.Disconnect;
   end;
 
   mail.Free;
   smtp.Free;
 end;
__________________
David Esperalta
www.decsoftutils.com

Última edición por dec fecha: 12-07-2005 a las 16:34:21. Razón: (corrección del texto)
Responder Con Cita