Ver Mensaje Individual
  #4  
Antiguo 19-07-2008
Avatar de white_zombie
[white_zombie] white_zombie is offline
Miembro Premium
 
Registrado: nov 2005
Ubicación: Zaragoza - España
Posts: 187
Reputación: 19
white_zombie Va por buen camino
Hola, una vez hice la prueba de enviar correos con html y me funciono, este es código:

Código Delphi [-]
var
  html: TStrings;
  partehtml: TIdText;
  partettxt:TIdText;
  partejpg: TIdAttachment;
  email: TIdMessage;
  filename: string;
begin
  filename := ExtractFilePath(Application.ExeName) + 'logo.jpg';

  html := TStringList.Create();
  html.Add('');
  html.Add('');
  html.Add('');
  html.Add('

Prueba

'
); html.Add(''); html.Add('Ahi va la FOTO!'); html.Add(''); email := TIdMessage.Create(nil); email.From.Text := 'yo@loquesea.com'; email.Recipients.EMailAddresses := 'yo@loquesea.com'; email.Subject := 'PRUEBA html'; email.ContentType := 'multipart/mixed'; email.Body.Assign(html); partettxt := TIdText.Create(email.MessageParts); partettxt.ContentType := 'text/plain'; partettxt.Body.Text := ''; partehtml := TIdText.Create(email.MessageParts, html); partehtml.ContentType := 'text/html'; partejpg := TIdAttachment.Create(email.MessageParts, filename); partejpg.ContentType := 'image/jpeg'; partejpg.FileIsTempFile := true; partejpg.ContentDisposition := 'inline'; partejpg.ExtraHeaders.Values['content-id'] := 'logo.jpg'; partejpg.DisplayName := 'logo.jpg'; with IdSMTP do begin // Configuro autentificación. AuthenticationType := atLogin; Username := 'Username'; // Nombre del usuario Password := 'Password'; // la password // Configuro el servidor SMTP. Host := 'Host'; Port := 25; try Connect; try // Envio el mensaje. Send(email); finally Disconnect; end; showMessage('Enviado Correctamente'); except // Capturo algunas excepciones que pueden ocurrir ON E: EIdProtocolReplyError do begin showmessage('No se ha podido enviar el email.' + #13 + 'Incorrecto el email o el usuario o la password.'); end; on E: EFOpenError do begin showMessage('No se ha podido enviar el email.' + #13 + 'Fichero Adjunto desconocido o erróneo.'); end; on E: EIdSocketError do begin showmessage('No se ha podido enviar el email.'+ #13 + 'Host desconocido o incorrecto.'); end; else begin showMessage('Fallo en el envio de email'); raise; end; end; if connected then IdSMTP.Disconnect; end; end;

Espero que te sirva de ayuda.

Un Saludo.
Responder Con Cita