Delphi: Indy search mailbox by skkeyword (thunderbird labels)
<p>I trying to get mail labels (setting by Thunderbird) from IMAP. I found some example procedures to search mailbox, but when I try to search by Keywords or Flags, Server disconnects. Below is code that I try to to proceed. IMAP server- Dovecot, Indy version 10</p>

<pre><code>IMAPClient.Connect;
if IMAPClient.SelectMailBox('INBOX') then
begin
  SetLength(SearchInfo, 1);
  SearchInfo[0].SearchKey := skkeyword; &lt;&lt;&lt;
  SearchInfo[0].Text := edit1.Text;
  if IMAPClient.SearchMailBox(SearchInfo) then
  begin
    memo1.Lines.add(inttostr(High(IMAPClient.MailBox.SearchResult))+ '-result');
    for I := 0 to High(IMAPClient.MailBox.SearchResult) do
    begin
      MsgObject := TIdMessage.Create(nil);
      try
        if IMAPClient.Retrieve(IMAPClient.MailBox.SearchResult[I], MsgObject) then
        begin
          memo1.Lines.Add(  msgobject.MsgId);
        end;
      finally
        MsgObject.Free;
      end;
    end;
  end;
end;
</code></pre>