Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-02-2012
Avatar de apicito
apicito apicito is offline
Miembro
 
Registrado: may 2003
Ubicación: Ourense
Posts: 341
Poder: 21
apicito Va por buen camino
Problema con envio de correos con fichero adjunto

estoy intentando mandar correos con ficheros adjuntos y me envia correctamente el correo pero el adjunto no.
Utilizo esto código:
Código:
procedure TCorreoSmtp.EnviarMail;
var SMTP: TIdSMTP;
   Mensaje: TIdMessage;
   Adjunto: TIdAttachmentFile;
   i: integer;
begin
  if trim(EDestinatario.Text)='' then begin
    Showmessage('Debe especificarse un destinatario');
    Exit;
  end;
  SMTP := TIdSMTP.Create( nil );
  SMTP.Username := sUsuario;
  SMTP.Password := sClave;
  SMTP.Host := sHost;
  try
    SMTP.Port := strtoint(sPort);
  except
    SMTP.Port := 25;
  end;
  SMTP.AuthType := satDEFAULT;       //satNONE, satDEFAULT, satSASL
  Mensaje := TIdMessage.Create( nil );
  Mensaje.Clear;
  Mensaje.ReplyTo.EMailAddresses := sReplyTo;
  with TIdText.Create(Mensaje.MessageParts, nil) do begin
    for i := 0 To Memo.Lines.Count -1 do
      SMensaje := SMensaje + '<br>' + Memo.Lines[i];
    Body.Text := sMensaje;
    ContentType := 'text/html';
  end;
  Mensaje.From.Name := sFromNome;
  Mensaje.From.Address := sFromEmail;
  Mensaje.Subject := sAsunto;
  if trim(sCopia)<>'' then begin
    Mensaje.BccList.Add;
    Mensaje.BccList.Items[0].Address := sCopia;
  end;
  Mensaje.Recipients.Add;
  Mensaje.Recipients.Items[0].Address := sDestino;

  if (sAdjunto <> '') and (FileExists( sAdjunto )) then begin
    Adjunto := TIdAttachmentFile.Create(Mensaje.MessageParts, sAdjunto);
    Mensaje.ContentType := 'multipart/related';
  end else begin
    Adjunto := nil;
    Mensaje.ContentType := 'multipart/alternative';
  end;

  try
     SMTP.Connect;
  except
    raise Exception.Create( 'Error al conectar con el servidor' );
  end;
  if SMTP.Connected then
  begin
     try
       SMTP.Send( Mensaje );
     except
       raise Exception.Create( 'Error al enviar el mensaje.' );
     end;
     try
        SMTP.Disconnect;
     except
       raise Exception.Create( 'Error al desconectar del servidor.' );
     end;
  end;
  if Adjunto <> nil then
     FreeAndNil( Adjunto );
  FreeAndNil( Mensaje );
  FreeAndNil( SMTP );
end;
Alguien ve algo raro en este código?
Un saludo.
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error en envío de mail con adjunto + Indy 10 agustibaldo Internet 8 23-01-2015 21:23:31
?Envio de correos ? jasmad Lazarus, FreePascal, Kylix, etc. 16 02-10-2012 15:45:02
Capturar error envio de correos con el evento OnFailedRecipient arante73 Internet 0 17-07-2007 10:05:54
Envio de Correos Masivo Esau Internet 2 10-04-2007 01:46:11
Obtener un fichero adjunto a un nodo de un fichero XML muntasil Internet 0 18-07-2006 12:57:57


La franja horaria es GMT +2. Ahora son las 23:10:49.


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