Re: TidPop3 connect and readtimeout

Giganews Newsgroups
Subject: Re: TidPop3 connect and readtimeout
Posted by:  Markku Uttula (markku.uttu…@disconova.com)
Date: Tue, 30 Mar 2004

Jhoe Logz wrote:
> how come there is no exception with my code?

How can you tell?

>  try
>      POP.Connect(6000);
>      FMsgCount := POP.CheckMessages;
>      Msg.Clear;
>      if FMsgCount > 0 then
>      begin
>        for i := 1 to FMsgCount do
>        begin
>          Msg.ClearBody;
>          POP.Retrieve(i, Msg);
>          for intIndex := 0 to Pred(Msg.MessageParts.Count) do
>          begin //body text
>            if Msg.MessageParts.Items[intIndex] is TIdText then
>            begin
>
> TidText(Msg.MessageParts.Items[intIndex]).Body.SaveToFile(ExeDir +
> 'SMSEmailTemp\' + IntToStr(DateTimeToUnix(Now)) + inttostr(i) +
>            '.txt'); end;
>          end;
>          Pop.Delete(i);
>        end;
>      end;
>    except
>      POP.Disconnect;
>    end;

Note that your exception handler only calls Pop.Disconnect ... Maybe
you should do something else? Something like ...

try
  POP.Connect(6000);
  try
  FMsgCount := POP.CheckMessages;
  Msg.Clear;
  if FMsgCount > 0 then
  begin
    for i := 1 to FMsgCount do
    begin
      Msg.ClearBody;
      POP.Retrieve(i, Msg);
      for intIndex := 0 to Pred(Msg.MessageParts.Count) do
      begin
        if Msg.MessageParts.Items[intIndex] is TIdText then
        begin
          TidText(
            Msg.MessageParts.Items[intIndex]
          ).Body.SaveToFile(
            ExeDir
            +
            'SMSEmailTemp\'
            +
            IntToStr(DateTimeToUnix(Now))
            +
            inttostr(i)
            +
            '.txt'
          );
        end;
      end;
      Pop.Delete(i);
    end;
  end;
  finally
    POP.Disconnect;
  end;
except
  on e:Exception do
  begin
    Debug('Exception occured => ' + E.Message);
  end;
end;

--
Markku Uttula

Replies

None

In response to

TidPop3 connect and readtimeout posted by Jhoe Logz on Tue, 2 Mar 2004