`SearchQuery.ToContains` doesn't return a result when the queried email contains capital letters
lobbo232 opened this issue · comments
Describe the bug
SearchQuery.ToContains
doesn't return a result when the queried email contains capital letters.
I am querying a catch all inbox and selecting emails based on their TO address, but SearchQuery.ToContains
isn't returning emails even when the to address matches exactly.
For example:
The inbox contains an email addressed to "LawnDrinkers@domain.co.uk" (I have redacted the actual users address but it's the same format).
I query the inbox using code like this:
var messages = IImapClient.Inbox.Search(SearchQuery.ToContains(user.EmailAddress))
where user.EmailAddress
equals "LawnDrinkers@domain.co.uk"
No message ID's are returned from the search.
If I was to do the following instead then the search results return as expected, despite the message To address being capitalised like the example above and the search query being all lower case.
var messages = IImapClient.Inbox.Search(SearchQuery.ToContains(user.EmailAddress.ToLower()))
Platform (please complete the following information):
- OS: Windows
- .NET Runtime: ASP.NET
- .NET Framework: .NET 4.8
- MailKit Version: 4.1.0
To Reproduce
Steps to reproduce the behavior:
- Send an email to a catch all inbox on your domain with the To Address in pascal case (e.g. LawnDrinkers@domain.co.uk)
- Query the inbox using the example above where your search query for
ToContains
is also in pascal case as above - See results not returned as expected
Expected behavior
The search query should either ignore casing of mail addresses or should match exactly rather than what it does above.
Ideally it would query case insensitively as email addresses are case insensitive.
This s something that clients have no control over as it relies on the server implementation.
Your only option is to do fetch the envelopes and do client-side string matching.