Continuação....

pra ficar mais claro vai o meu código,

function TForm1.manda_email(end_to, destinatario, assunto, body,
replyto,smtp_server, smtp_usuario, smtp_senha, smtp_nome : string;
tentativa : Integer): boolean;
var
mail: TStringList;
begin
 try
  result:=true;
  Application.ProcessMessages ;
  MailMessage.From.Address:= smtp_usuario;
  MailMessage.From.Name:=smtp_nome;
  MailMessage.Recipients.EMailAddresses := destinatario + '<' + end_to
+ '>' ;
  MailMessage.Subject := assunto ;
  MailMessage.ReplyTo.Add.Address := replyto  ;
  MailMessage.ContentType :='text/html';
  MailMessage.Body.Add(body);

     
   try
    if(SMTP.Connected = false) then
     begin

      SMTP.Username :=Trim (smtp_usuario) ;
      SMTP.Password :=Trim (smtp_senha) ;
      SMTP.Host := Trim (smtp_server);
      smtp.AuthType :=atDefault;
      SMTP.Connect ;
     end;
   except on E: Exception do
    begin
      AddErro('Erro conectando ao Servidor SMTP Tentativa - '+
IntToStr(tentativa +1) +' [' + E.Message + ']');
      result:=false;
    end;
      end;

    if(SMTP.Connected = true) then
     begin      
      try
       {Erro bem aki no send =/}
       SMTP.Send(MailMessage);
       Application.ProcessMessages ;
      except on E: Exception do
       begin
        AddErro('Erro Enviando E-mail Tentativa - '+
IntToStr(tentativa+1) +' ['+ end_to +']:' + E.Message);
        result:=false;
       end;
      end;
     end


 finally
  MailMessage.Clear ;
  if(result = false) and(tentativa = 0) then
   begin
    while(tentativa < gTentativas) do
     begin
      tentativa := tentativa +1;
      try
       if manda_email(end_to, destinatario, assunto, body,
replyto,smtp_server, smtp_usuario, smtp_senha, smtp_nome, tentativa) then
        begin
         result := true;
         Break;
        end;
       except
       end; 
     end;

   end;
 end;
end;


a maioria dos erros é "Connection Closed Gracefully" o problema não é
o erro eh q aparece um alerta para o usuario fazendo com que ele
clique no "OK" ... =/ se alguem puder me ajudar fico grato...





Responder a