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.