We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PersonalStorageQueryBuilder and queries by specific keywords

Hi Team,
I am trying to filter in mails containing specific keywords.
Is there a way to pass multiple arguments for searching keyword in pst file using PersonalStorageQueryBuilder. Tried list and using ‘or’ does not seem to work. Also, is text.contains the right way to search if the keyword is either in subject or body? This doesnt seem to work, I get, “Proxy error: pst searching engine does not support “Text” as field name”. Is it possible to get only the filtered mails into new pst file?
Please help me with this

queryBuilder = PersonalStorageQueryBuilder()
queryBuilder.subject.contains(“Review” or “Error”)

queryBuilder.body.contains(“Review” or “Error”)
messageInfoCollection = folderInfo.get_contents(queryBuilder.get_query())

I also tried creating two instances of queryBuilder i.e. queryBuilder and queryBuilder1 and passing them into get_contents with or in between. That didnt work either.

Thank you for the questions. I will answer you as soon as possible.


I added a ticket with ID EMAILNET-40255 to our tracking system. Our development team will investigate this possibility. I will inform you of any news.

Yes, text.contains method must search for a text sample in the headers and body of a message. Could you share the PST file and code example reproducing the error, please?

Please take a look at the next article: Working with Messages in a PST File.

Our development team investigated your requirements for using multiple arguments for searching specific keywords in PST files. There are several ways to construct a query using a disjunction. All ways will lead to the same result.

Using multiple builders and the Or method:

PersonalStorageQueryBuilder builder1 = new PersonalStorageQueryBuilder();
PersonalStorageQueryBuilder builder2 = new PersonalStorageQueryBuilder();
PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder();
queryBuilder.Or(builder1.GetQuery(), builder2.GetQuery());

MessageInfoCollection messageInfoCollection = test.GetContents(queryBuilder.GetQuery());

Using one builder, multiple MailQuery, and the Or method:

PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder();
queryBuilder.Or(new MailQuery("'Subject' Contains 'Review'"), new MailQuery("'Subject' Contains 'Error'"));

MessageInfoCollection messageInfoCollection = test.GetContents(queryBuilder.GetQuery());

Using only MailQuery:

MessageInfoCollection messageInfoCollection = test.GetContents(new MailQuery("'Subject' Contains 'Review'|'Subject' Contains 'Error'"));

We will update the documentation later. Thank you for your patience.