How to find messages in the selected mailbox on the IMAP server

procedure TForm1.btnFindClick(Sender: TObject);   
var   
   MsgNumbers: TStrings;   
begin   
   clIMAP4.Server := 'mail.test.com';   
   clIMAP4.UserName := 'test';   
   clIMAP4.Password := 'test';   
   clIMAP4.UseTLS := ctNone;   
   clIMAP4.UseSasl := False;   
   clIMAP4.Open();   
 
   clIMAP4.SelectMailBox('MyMailbox');   
 
   MsgNumbers := TStringList.Create();   
   try   
      clIMAP4.SearchMessages('SUBJECT hello', MsgNumbers);   
 
      ShowMessage(MsgNumbers.Text);   
   finally   
      MsgNumbers.Free();   
   end;   
 
   clIMAP4.Close();   
end; 

Add Feedback