IdSMTP error while sending Message

Giganews Newsgroups
Subject: IdSMTP error while sending Message
Posted by:  Zugg (lezu…@hotmail.com)
Date: Thu, 2 Oct 2008

Hello,

Indy 9.00.10 + Delhpi 7

I have create a Windows service who send email thank to IdSMTP. All works
fine, but sometimes I'have got this error message in log file : "No body
content sent with message (0 bytes sent)" when TIdSMTP.Send(..) method is
call.

Some email with the same message are correctly sent, but some are not due to
this error.

What's wrong ?

Code sample :

IdMsgWarning.ContentType := 'text/plain';
IdMsgWarning.From.Address := .....
IdMsgWarning.Subject := FindSubjectInDatabase(...);
lstMessage.Text := FindMessageInDatase(...);
try
  lTmpBody := MessageComputing(lstMessage);
  IdMsgWarning.Body.Text := lTmpBody.Text;
finally
  lstMessage.Clear;
  lstMessage.Free;
  if lTmpBody <> nil then
    lTmpBody.Free;
  end;
end
error := false;
IdMsgWarning.Recipients.EMailAddresses := recipient;
if IdMsgWarning.Recipients.EMailAddresses = '' then
begin
            WriteLog('Empty e-mail');
            error := true;
end
else
begin
  WriteLogLocal(Email sending');
  error := false;
  try
    IdSMTP.Connect(900);
  except
    on e: exception do
    begin
      writelog('Exception connect => ' + e.message);
      error := true;
    end;
  end;
  try
    IdSMTP.send(IdMsgWarning);
  except
    on e: exception do
    begin
      writelog('Exception send => ' + e.message);
      error := true;
    end;
  end;
  sleep(2000);
  try
    IdSMTP.Disconnect;
  except
    on e: exception do
      writelog('Exception disconnect => ' + e.message);
    end;
  except
    error := true;
  end;
end;

Thanks in advance.
--
Zugg

Replies