This project is read-only.

Imap search query with non ascii characters (gmail)

Topics: Feature Requests
Jul 20, 2013 at 12:02 AM
Edited Jul 20, 2013 at 12:31 AM

Im trying to search my inbox for a collection of e-mails using their subject name. unfortunately they contain some swedish characters which are not part of ascii. im guessing thats the cause since im not getting any hits when searching for words containing these characters (åäö).

is there a way for me to work around this issue?

code example:
ImapX.MessageCollection messages = _client.Folders["INBOX"].Search("SUBJECT Bärtz", true);
Jul 22, 2013 at 12:28 PM
Hi thesquig,

i found a solution for this issue, the code update will be available on Wednesday (24th) and I will give you more details on how to use the search command with unicode queries.

Best regards,

Pavel Azanov
Jul 22, 2013 at 2:23 PM
thats great, thx a lot! :)
Jul 24, 2013 at 9:25 AM
Edited Jul 24, 2013 at 9:25 AM
Good day, thesquig!

i updated the code in the repository, it contains the changes needed to allow unicode search queries.

The query Looks this way:
var subject = "Bärtz";
ImapX.MessageCollection messages = _client.Folders["INBOX"].Search("CHARSET UTF-8 SUBJECT {" + Encoding.UTF8.GetByteCount(subject) + "}\r\n" + subject, true);
If you have more questions, feel free to ask. I want to remind you that the code in the repository is pre-release, so might be unstable.

Best regards,

Pavel Azanov
Jul 25, 2013 at 2:02 PM
Great! Ive tried it out and it works. Thank you very much for your effort :)
Jul 26, 2013 at 3:19 PM
Hi thesquig,

great to hear it works fine! I'm planning to make another update, so you don't have to specify the charset and the number of bytes for each string yourself, this will happen automatically.

I'll let you know when the update is ready.