Search code examples
.netimapmailkit

MailKit IMAP Search Body doesn't find email with capital letters


I'm using MailKit as means of email automation. One of the basic search of emails in the inbox is by body text content matching, however if the search is made either with the word capitalized or in uppercase then it returns no entries. This behavior is strange as when doing a subject search, the same word is found when requested in its capitalized/uppercased form. When looking the IMAP SEARCH command specification it states that the matching is case insensitive, so this is rather strange.

I have a simple email as follows:

Subject: CAPITAL Word | Body: CAPITAL Word body test | Body content: Plain

Looking at the logs here's the commands being sent to the IMAP server:

  • UID SEARCH BODY CAPITAL - this does not return the email

  • UID SEARCH BODY Word - this does not return the email

  • UID SEARCH BODY word - this returns the email

  • UID SEARCH BODY capital - this returns the email

  • UID SEARCH OR BODY CAPITAL BODY capital - this returns the email

  • UID SEARCH SUBJECT CAPITAL - this returns the email, showing that the subject search using uppercased words works

The IMAP server I'm accessing is the Outlook server, is this something related to the server, to the IMAP command not accepting a uppercased or capitalized word, or something else entirely?


Solution

  • It seems that this situation was being caused by an issue with the server not finding the emails according to my search, as commented by @Max, going to close this question.