Reputation: 25
I get this error when I use the search command with special charachter in searchPhrase like "سلام" it works fine in other cases. I've also tried encoding to UTF-8. there is no error then but it doesn't give back any result.
var uids = Client.Inbox.Search(SearchQuery.SubjectContains(searchPhrase));
any suggestion?
Upvotes: 1
Views: 2245
Reputation: 38548
I just tested this on GMail using MailKit and this is what I get:
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)
What is the error? Seems to work fine for me (other than the fact that I obviously don't have any messages with that string in the Subject header).
Here is my little test program:
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 ("[email protected]", "xxx");
client.Inbox.Open (FolderAccess.ReadOnly);
client.Inbox.Search (SearchQuery.SubjectContains ("سلام"));
client.Disconnect (true);
}
}
}
}
Upvotes: 3