Hi Karthik,
Thank you for contacting Aspose support team.
It may take long time if query is not properly designed. You may please add time filter along with other filters to improve the performance. Please give a try to the following sample code and share the feedback.
ImapClient client = new ImapClient("http://exchange.domain.com/", 143, "user@domain.com", "password", SecurityOptions.None);
client.SelectFolder(ImapFolderInfo.InBox);
// Set conditions, Subject contains "Newsletter", Emails that arrived today
ImapQueryBuilder builder = new ImapQueryBuilder();
builder.Subject.Contains("Required Subject");
builder.InternalDate.Since(DateTime.Now.AddHours(-24));
// Build the query and Get list of messages
MailQuery query = builder.GetQuery();
ImapMessageInfoCollection messages = client.ListMessages(query);
Console.WriteLine("Imap: " + messages.Count + " message(s) found.");
// Disconnect from IMAP
client.Dispose();
If you are using pop3Client, please use sample code here.