IMAP 服务器用 'NO' 响应回复了 'SEARCH' 命令:搜索不支持字符集

The IMAP server replied to the 'SEARCH' command with a 'NO' response: Character set not supported for search

当我在 searchPhrase 中使用带有特殊字符的搜索命令时出现此错误,例如“سلام” 它在其他情况下工作正常。我也尝试过编码为 UTF-8。然后没有错误,但它不会返回任何结果。

var uids = Client.Inbox.Search(SearchQuery.SubjectContains(searchPhrase));

有什么建议吗?

我刚刚使用 MailKit 在 GMail 上对此进行了测试,这就是我得到的结果:

S: A00000006 OK [READ-ONLY] INBOX selected. (Success)
C: A00000007 UID SEARCH RETURN () CHARSET UTF-8 SUBJECT {8+}
C: سلام
S: * ESEARCH (TAG "A00000007") UID
S: A00000007 OK SEARCH completed (Success)

错误是什么?对我来说似乎工作正常(除了我在主题 header 中显然没有任何带有该字符串的消息)。

这是我的小测试程序:

using System;

using MailKit.Net.Imap;
using MailKit.Search;
using MailKit;
using MimeKit;

namespace GMailSearchTest {
    class Program
    {
        public static void Main (string[] args)
        {
            using (var client = new ImapClient (new ProtocolLogger (Console.OpenStandardOutput ()))) {
                // For demo-purposes, accept all SSL certificates
                client.ServerCertificateValidationCallback = (s,c,h,e) => true;

                client.Connect ("imap.gmail.com", 993, true);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove ("XOAUTH2");

                client.Authenticate ("xxx@gmail.com", "xxx");

                client.Inbox.Open (FolderAccess.ReadOnly);
                client.Inbox.Search (SearchQuery.SubjectContains ("سلام"));

                client.Disconnect (true);
            }
        }
    }
}