idMessage.MessageParts.Count sometimes return 0 while there is parts, Indy 10

Giganews Newsgroups
Subject: idMessage.MessageParts.Count sometimes return 0 while there is parts, Indy 10
Posted by:  Tomas (tom…@gmail.com)
Date: Thu, 10 Apr 2008

Hi,

I use idPOP to download messages from Gmail and extract attachments,
after upgrading from 9 to Indy 10 I noticed that sometimes
idMessage.MessageParts.Count
return zero (0) while message contain body and attachments. Is this some
kind of bug?

What is the latest version of Indy? I have 10.1.5.

      idPOP.Password := AMailPass;
      idPOP.Port := StrToInt(AMailPort);
      idPOP.Host := AMailHost;
      idPOP.Username := AMailUser;
      if AMailUseTLS = false then
      begin
      idPOP.UseTLS:=utNoTLSSupport;
      end;

      try
        if idPOP.Connected = false then idPOP.Connect;
        NumMsgs := idPOP.CheckMessages;

        Memo.lines.add(DateTimeToStr(Now) + ' ' + 'Emails:' +
IntToStr(NumMsgs));

        if NumMsgs > 0 then
        begin
          idPOP.Retrieve(1, idMessage);
          Memo.Lines.Add('Email Nº: 1'  + ' From:' + idMessage.From.Text + '
Subject:' + idMessage.Subject);

          for cik_attachment := 0 to idMessage.MessageParts.Count - 1 do
          begin
            if idMessage.MessageParts.Items[cik_attachment] is
TIdAttachmentFile then
            begin
              AAttachmentFileName :=
TIdAttachmentFile(idMessage.MessageParts.Items[cik_attachment]).FileName;
              AAttachmentLocation :=
TIdAttachmentFile(idMessage.MessageParts.Items[cik_attachment]).StoredPathName;

Regards,
Tomas

Replies