Ver Mensaje Individual
  #19  
Antiguo 02-07-2007
Phantom_Drake Phantom_Drake is offline
Miembro
 
Registrado: jun 2007
Posts: 13
Reputación: 0
Phantom_Drake Va por buen camino
ke onda otra vez dando lata aki otra duda
tengo este codigo para mandar el correo con imagen pero nomas no puedo poner la imagen de fondo en el correo solo sale despues del texto alguien me puede ayudar por favor
Código Delphi [-]
procedure TFrm_Email.Button2Click(Sender: TObject);
var I,J,K,L:Integer;
    cadena,correo:string;
    Check: TcheckBox;
    ChildControl: TControl;
    html: TStrings;
    htmpart, txtpart: TIdText;
    bmppart: TIdAttachment;
    email: TIdMessage;
    //archiv:TStrings;
    filename,ss,filename1: string;
    a:Integer;
    idStars:   TIdAttachment;
    //archiv:t;
begin
  Redt_Texto.Lines.SaveToFile('C:\WINDOWS\EMKTMP.RTF');
  r2hconv.rtf2html('C:\WINDOWS\EMKTMP.RTF', 'C:\WINDOWS\EMKTMP.HTM',['']);
  try
    RichEdit2.lines.LoadFromFile('C:\WINDOWS\EMKTMP.HTM');
    for A:=0 to RichEdit2.lines.Count -1 do
    begin
     SS:=RichEdit2.Lines.Strings[A];
     RichEdit1.Lines.Add(SS);
    end;
  finally
  richedit1.Lines.Add('');
  richedit1.Lines.Add('');
  richedit1.Lines.Add('');
    //RichEdit2.Free;
  end;
 
  if DBLookupComboBox1.Text='' then
    ShowMessage('debe seleccionar un formato')
  else
  begin
    Lst_Mails.Items.Clear;
    with dtm_contactos.Qry_Correos do
    begin
      Close;
      SQL.Clear;
      cadena:='select email from contactos where grupo<''0'' ';
      for I := 0 to GroupBox9.ControlCount - 1 do
        if GroupBox9.Controls[i] is TCheckBox then
          if TCheckBox(GroupBox9.Controls[i]).Checked then
            cadena:=cadena+ ' or grupo='''+(IntToStr(i+1))+'''';
      sql.Add(cadena);
      Open;
      First;
      if Lst_Correos.Items.Count > 0 then
        Lst_Mails.Items:=Lst_Correos.Items;
      while not Eof do
      begin
        Lst_Mails.Items.Add(fieldbyname('email').AsString);
        next;
      end;
    end;
    Lst_Correos.Items.Clear;
    for K:=0 to Lst_Mails.Items.Count -1  do
    begin
      correo:= Lst_Mails.Items.Strings[k];
      CopyFile(PChar('C:\Proyecto Email\Formatos\'+ DBLookupComboBox1.text ),PChar('C:\Archivos de programa\Borland\Delphi7\Projects\'+ DBLookupComboBox1.text),TRUE);
      //filename := ExtractFilePath(Application.ExeName) + '\homerorx.jpg';
      //filename1 := 'C:\Proyecto Email\Formatos\'+ DBLookupComboBox1.text + '''';
      filename := 'C:\Proyecto Email\Formatos\'+ DBLookupComboBox1.text ;
      html := TStringList.Create();
      {html.Add('');
      html.Add('');
      html.Add('');
      html.Add(' 

Hello

'); //html.Add(''); html.Add(''); html.Add('');}
for L:=0 to RichEdit2.lines.Count -1 do begin html.Add(RichEdit2.Lines.Strings[L]); end; email := TIdMessage.Create(nil); email.From.Text := 'origen'; email.Recipients.EMailAddresses := correo; email.Subject := 'Hello'; email.ContentTransferEncoding:= 'multipart/related'; email.IsEncoded:=true; email.Body.Assign(html); txtpart := TIdText.Create(email.MessageParts); txtpart.ContentType := 'text/html'; txtpart.Body.Text := RichEdit2.Text; htmpart := TIdText.Create(email.MessageParts, html); htmpart.ContentType := 'text/html'; bmppart := TIdAttachment.Create(email.MessageParts, filename); bmppart.ContentType := 'image/jpeg'; bmppart.FileIsTempFile := false; bmppart.contenttransfer:='base64'; bmppart.ContentDisposition := 'inline'; bmppart.ExtraHeaders.Values['Content-ID'] := ''; try SMTP.Host:='server'; SMTP.Port:=25; SMTP.Connect(); try SMTP.Send(email); ShowMessage('Sent'); except on E: Exception do ShowMessage('Failed: ' + E.Message); end; finally SMTP.Disconnect(); email.Free(); html.Free(); end; end; end;
Responder Con Cita