{"action":"created","issue":{"url":"https://api.github.com/repos/jstedfast/MailKit/issues/164","labels_url":"https://api.github.com/repos/jstedfast/MailKit/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/jstedfast/MailKit/issues/164/comments","events_url":"https://api.github.com/repos/jstedfast/MailKit/issues/164/events","html_url":"https://github.com/jstedfast/MailKit/issues/164","id":62029996,"number":164,"title":"Problem when applying an OrderBy to a SearchQuery on an IMAP  Folder","user":{"login":"silaing","id":11499869,"avatar_url":"https://avatars.githubusercontent.com/u/11499869?v=3","gravatar_id":"","url":"https://api.github.com/users/silaing","html_url":"https://github.com/silaing","followers_url":"https://api.github.com/users/silaing/followers","following_url":"https://api.github.com/users/silaing/following{/other_user}","gists_url":"https://api.github.com/users/silaing/gists{/gist_id}","starred_url":"https://api.github.com/users/silaing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silaing/subscriptions","organizations_url":"https://api.github.com/users/silaing/orgs","repos_url":"https://api.github.com/users/silaing/repos","events_url":"https://api.github.com/users/silaing/events{/privacy}","received_events_url":"https://api.github.com/users/silaing/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jstedfast/MailKit/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-16T09:54:02Z","updated_at":"2015-03-18T18:07:34Z","closed_at":null,"body":"Hi\r\nI have been trying to apply a number of OrderBy arguments to a SearchQuery on an open IMAP mail folder as per some of the examples you provide. If I run the Search without the orderBy argument it works fine and returns all the UniqueIds. Applying an OrderBy, however, throws an exception \r\n\r\n\"The IMAP server replied to the 'SORT' command with a 'NO' response.\". \r\n\r\nIs there anything I'm missing out?\r\n\r\nvar orderBy = new[] { OrderBy.From };\r\nvar query = SearchQuery.All;\r\nvar resul  = folder.Search(query, orderBy);\r\n\r\nthank you for any help."},"comment":{"url":"https://api.github.com/repos/jstedfast/MailKit/issues/comments/83104477","html_url":"https://github.com/jstedfast/MailKit/issues/164#issuecomment-83104477","issue_url":"https://api.github.com/repos/jstedfast/MailKit/issues/164","id":83104477,"user":{"login":"jstedfast","id":338984,"avatar_url":"https://avatars.githubusercontent.com/u/338984?v=3","gravatar_id":"","url":"https://api.github.com/users/jstedfast","html_url":"https://github.com/jstedfast","followers_url":"https://api.github.com/users/jstedfast/followers","following_url":"https://api.github.com/users/jstedfast/following{/other_user}","gists_url":"https://api.github.com/users/jstedfast/gists{/gist_id}","starred_url":"https://api.github.com/users/jstedfast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstedfast/subscriptions","organizations_url":"https://api.github.com/users/jstedfast/orgs","repos_url":"https://api.github.com/users/jstedfast/repos","events_url":"https://api.github.com/users/jstedfast/events{/privacy}","received_events_url":"https://api.github.com/users/jstedfast/received_events","type":"User","site_admin":false},"created_at":"2015-03-18T18:07:34Z","updated_at":"2015-03-18T18:07:34Z","body":"The problem is not the charset or even the charset param, the problem is that MailKit was sending a command like this:\r\n\r\n```\r\nC: B00000008 UID SORT (FROM) RETURN () US-ASCII ALL\r\n```\r\n\r\nWhen it *should* have been sending:\r\n\r\n```\r\nC: B00000008 UID SORT RETURN () (FROM) US-ASCII ALL\r\n```\r\n\r\nIn other words, the IMAP server was expecting a charset name after the sort-order parameter but instead found the \"RETURN\" token, hence the error message being \"NO [BADCHARSET] parse error: unknown charset: RETURN\".\r\n\r\nSo this is a bug in MailKit, not the IMAP server.\r\n\r\nIt would be nice if you could confirm my diagnosis with the actual command from the log to make sure I'm  correct."}}