Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Acerca de enviar texto con formato... (https://www.clubdelphi.com/foros/showthread.php?t=18819)

CORBATIN 11-07-2007 17:22:33

Aquí tengo lo que he formado pero me da un error y es el siguiente.
Cuando le doy a enviar la primera vez sale todo perfecto, pero si cambio la dirección de correo para enviarselo a otro, entonces me sale el error de EidProtocolReplyError 553 RCPT REFUSED.

Aquí tienen el codigo
Código Delphi [-]
procedure EnviarHtml(aText: String;ruta,destino:string;aImagenes:array of string);
var
  idAttach: TidAttachment;
  idText1: TidText;
  idText2: TidText;
  p: TidMessageParts;
  idMessage1: TidMessage;
  slBody: TStringList;
  idSMTP1: TidSMTP;
  x:integer;
begin
  idMessage1 := TIdMessage.create(nil);
  idMessage1.Recipients.Add;
  idMessage1.Recipients[0].Address := destino;
  idMessage1.subject := 'OFERTAS';
  //idMessage1.from.Text := 'PACO J GARCIA.';

  p := idMessage1.MessageParts;
  slBody := TstringList.Create;
 try
  try
   idSMTP1 := TidSMTP.create(nil);
   idSMTP1.AuthenticationType :=atLogin;
   idSMTP1.Port := 25;
   idSMTP1.Host := 'smtp.ono.com';
   idSMTP1.UserId :='upimolina@ono.com';
   idSMTP1.Password := 'OLIMPICO';
    // you can actually load the body from a RichEdit with
    // slBody.Text := RichEdit1.LinesText;
    slBody.Add(atext);
    idText1 := TidText.Create(p, slBody);
    idText1.ContentType := 'text/html';
    idText2 := TidText.Create(p);
    idText2.ContentType := 'text/plain';
    idText2.Body.Text := '';
    // This shows how to add an attachment
    for x := 0 to 3 do
    begin
     if (length(aImagenes[x]) > 0) then
     begin
      idAttach := TidAttachment.Create(p, ruta+aImagenes[x]);
      idAttach.ContentType := 'image/jpeg';
      idAttach.ContentDisposition := 'inline';
      idAttach.ExtraHeaders.Values['content-id'] := aImagenes[x];
      idMessage1.Body.Assign(slBody);
      idAttach.DisplayName := aImagenes[x];
      idMessage1.ContentType := 'multipart/mixed';
     end;
    end;
    idSMTP1.Connect;
    idSMTP1.Send(idMessage1);
  finally
    idSMTP1.Disconnect;
    idMessage1.Free;
    slBody.Free;
    Showmessage('enviado');
  end;
 except
  showmessage('Error al enviar el e-mail, consulte con su administrador.');
 end;
end;

Haber si alguién me puede decir a que se debe ese motivo y tener en cuenta que todavía lo estoy depurando, gracias.

Phantom_Drake 11-07-2007 18:09:56

ps como no he tenido tiempo de acomodar el ejemplo ahi te va el codigo espero ke le puedas entender por ke esta todo desacomodado alguna duda no hay pex tu pregunta
Código Delphi [-]
procedure TFrm_Email.Button2Click(Sender: TObject);
var I,J,K,L,enviados:Integer;
    cadena,correo:string;
    Check: TcheckBox;
    ChildControl: TControl;
    html: TStrings;
    htmpart, txtpart: TIdText;
    bmppart: TIdAttachment;
    email: TIdMessage;
    //archiv:TStrings;
    filename,ss,filename1: string;
    a,count:Integer;
    idStars:   TIdAttachment;
    //archiv:t;
begin
  bandera:=true;
  enviados:=0;
  count:=0;
  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('
'
); richedit1.Lines.Add('
'
); richedit1.Lines.Add('
'
); richedit1.Lines.Add('
'
); richedit1.Lines.Add('
'
); 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; ProgressBar1.Max:=Lst_Mails.Items.Count; Timer1.Enabled:=True; end; for K:=0 to Lst_Mails.Items.Count -1 do begin ProgressBar1.Position:=k+1; 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 do begin html.Add(RichEdit2.Lines.Strings[L]); end; email := TIdMessage.Create(self); email.From.Text := 'correo'; email.Recipients.EMailAddresses := correo; email.Subject := 'Aviso Muelle 7'; email.ContentType := 'text/html'; email.charset := 'iso-8859-1'; 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'; //htmpart.charset := 'iso-8859-1'; bmppart := TIdAttachment.Create(email.MessageParts, filename); bmppart.ExtraHeaders.Values['Content-ID'] := ''; bmppart.ContentType := 'image/html'; //bmppart.charset := 'iso-8859-1'; } try SMTP.Host:='smtp.prodigy.net.mx'; SMTP.Port:=25; If (k=0) OR (count=0)then SMTP.Connect(); try count:=count+1; SMTP.Send(email); //ShowMessage('Sent'); except on E: Exception do begin //ShowMessage('Failed: ' + E.Message); SMTP.disConnect(); SMTP.Connect(); SMTP.Send(email); end; end; end; finally email.Free(); html.Free(); if count=14 then begin SMTP.Disconnect; count:=0; end; enviados:=enviados+1; Label2.Caption:=IntToStr(enviados); end; end; ProgressBar1.Position:=0; ShowMessage('Mensajes Enviados Satisfactoriamente: ' + IntToStr(enviados)); SMTP.Disconnect(); end;
por cierto tambien tengo un problema con este solo me permite mandar hasta 70 correos alguien sabe como hacerle para ke no me rechaze la coexion el server?:o

CORBATIN 17-07-2007 22:53:09

Hola de nuevo, le he realizado algunas reforma a mi aplicacion de enviar e-mail con html y fotos y va genial.

Ahora tengo un problema, al enviar a una direccion de hotmail, las fotos que incluye el email en html salen como adjuntos y no en el html. En cambio, en los clientes de correo como express o outlook se ven perfectos.

Por que puede pasar esto?.

GRACIAS.

Phantom_Drake 17-07-2007 22:56:11

hehe a mi me pasa lo mismo pero alrevez en cuando reviso los correos en paginas web se miran perfectamente pero cuando los abro en los clientes de correo no sale la imagen deberiamos de juntar los proyectos y saldria el completo :p

CORBATIN 24-07-2007 20:36:43

Hola, perdonar el retraso de tantos días. Lo que ha dicho no sería mala idea, si te es posible, pon tú código para enviar e-mail y yo el mío de nuevo y entre ambos podremos encontrar el error y sacar uno ok.

Te estaría agradecido, gracias.


La franja horaria es GMT +2. Ahora son las 10:11:59.

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