为什么 TIdMailBox.UnseenMsgs 属性 return 0 值?

Why does the TIdMailBox.UnseenMsgs property return 0 value?

我正在尝试使用来自 Indy 10.6.0.4975 的 TIdIMAP4 获取我的 IMAP 邮箱的未读消息数。

问题是 UnseenMsgs 属性 returns 0 即使访问的邮箱中有一些未读邮件。这是我使用的代码:

procedure TForm1.FormClick(Sender: TObject);
var
  TotalMsgs: Integer;
  UnseenMsgs: Integer;
begin
  IdIMAP41.Connect(True);
  IdIMAP41.SelectMailBox('Inbox');

  TotalMsgs := IdIMAP41.MailBox.TotalMsgs; // returns correct value
  UnseenMsgs := IdIMAP41.MailBox.UnseenMsgs; // <- returns always 0

  IdIMAP41.Disconnect(False);
end;

为什么 TIdMailBox.UnseenMsgs 属性 return 0 而不是正确的数字?

StatusMailBox method before you access that property. It is mentioned in the UnseenMsgs 属性 文档称为:

UnseenMsgs is updated when the results from the TIdIMAP4.StatusMailBox method are parsed.

所以这样做:

IdIMAP41.Connect(True);
IdIMAP41.SelectMailBox('Inbox');
IdIMAP41.StatusMailBox('Inbox', IdIMAP41.MailBox);

UnseenMsgs := IdIMAP41.MailBox.UnseenMsgs;