Check Unread Messages with Indy

I am making an application for reading unread messages in Delphi for fun. I use Indy 10. I can connect to Gmail and receive all messages, but I have a problem: I canโ€™t tell if the message has been read or not. The TidMessage component has a flag property that should tell me if a message has been read. The code is as follows:

procedure TForm1.btTestConnectionClick(Sender: TObject);
var
 i: Integer;
 count: Integer;
 flag: TIdMessageFlags;
begin
 if (pop3Test.Connected) then begin
  pop3Test.Disconnect;
 end;

 pop3Test.Username := edAccount.Text;
 pop3Test.Password := edPassword.Text;
 pop3Test.Host := HOST;
 pop3Test.AuthType := patUserPass;
 pop3Test.Port := PORT;
 pop3Test.Connect;
 Count := 0;
 for i := pop3Test.CheckMessages downto 1 do begin
      pop3Test.Retrieve(i, IdMessage1);
      if (mfSeen in IdMessage1.Flags) then begin
       Count := Count + 1;
      end;
 end;


 ShowMessage(IntToStr(Count));
 pop3Test.Disconnect;
end;

There is one unread message in the test mailbox, but all received messages have the enum flags property, so the result is always 0. Am I doing something wrong? Is this an Indy / Gmail compatibility issue?

Thank.

EDIT: I am definitely doing something wrong, since testing with a Hotmail account shows the same problem with the properties of empty flags.

+3
2

POP3 Message state information , , , . IMAP for Gmail.

+13

( ) Indy "mfSeen". idIMAP *. RRUZ - POP3 . POP3 . IdMessage IMAP POP3.

TIdMessageFlags, , TIdIMAPMessageFlags

+3

Source: https://habr.com/ru/post/1782682/


All Articles