Hi,
I’m working with Exchange mail client. While I’m filtering mail by To.Address field it doesn’t work.
Filtering by To.DisplayName - works fine.
In addition, I have the same problem while I’m filtering by From fields but in the opposite:
While I’m filtering mail by From.Address field it works well.
Filtering by From.DisplayName - doesn’t work.
Here below my snippet code: Creating Query:
MailQuery mq = null;
ExchangeQueryBuilder qb = new ExchangeQueryBuilder();
qb.Or(qb.From.Contains(pFromAddress), qb.From.Contains(pFromName));
qb.To.Contains(pTo);
mq = qb.GetQuery();
return mq;
Create mail client:
NetworkCredential credentials = new NetworkCredential(UserName, Password, Domain);
IEWSClient MailClient = EWSClient.GetEWSClient(ServerHost, credentials);
Get mails by query:
MailClient.ListMessages(pSubfolderUri, pMaxResult, pMailQuery); --> this line returns 0 mails count although there is a mail matched to query.
Note that if I’m testing this code while I’m using IMAP server - I got results.
Additional info:
Working with Aspose.Email version 19.6.0.0
I tried it on IMAP server in office365 - https://outlook.office365.com/EWS/Exchange.asmx
Unfortunately, I can’t attach user & password to tested mail.
I have observed the issue shared by you and request you to please first try using latest Aspose.Email for .NET 19.11 on your end. In case the issue is still reproduced, please share the working sample project reproducing the issue on your end along with test account access.
I have worked with the sample project shared. An issue with ID EMAILNET-39686 has been created in our issue tracking system to investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.
The issue associated in this thread has been marked as resolved in upcoming Aspose.Email for .NET 20.6. We have added a search option by using Advanced Query Syntax (AQS). This feature will solve the issue.
New API members
ExchangeAdvancedSyntaxQueryBuilder class - represents the builder of search expression based on the Advanced Query Syntax (AQS) ExchangeAdvancedSyntaxMailQuery class - implements an Advanced Query Syntax (AQS) search that is used by EWS.