jonhoo / rust-imap

IMAP client library for Rust
Apache License 2.0
477 stars 80 forks source link

Feature request: support search Non-ASCII characters #278

Open Tsai002 opened 7 months ago

Tsai002 commented 7 months ago

Use uid_search directly

let query = "UID SEARCH CHARSET UTF-8 BODY {6}\r\n测试";
imap_session.uid_search(query)

resp: Error: Unexpected Response: Continue { code: None, information: Some("send literal data") }

Use run_command_and_read_response

let query = "UID SEARCH CHARSET UTF-8 BODY {6}\r\n测试";
let rsp = imap_session.run_command_and_read_response(query).unwrap();
println!("{:?}", String::from_utf8_lossy(&rsp));

resp: "+ send literal data\r\n* SEARCH 11111\r\n* FLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen $Forwarded $MDNSent Forwarded $Junk $NotJunk Junk JunkRecorded NonJunk NotJunk $label3 $label2 $label4)\r\n"

ref: https://stackoverflow.com/questions/10131131/imap-search-command-with-utf-8-charset-in-c-sharp

jonhoo commented 7 months ago

Oh, I didn't even know about this feature! I agree, this would be a good thing to support :+1: PRs welcome :sweat_smile: It might require a dedicated command variant though since the expected response from the server is different :thinking: