0
我想在C#創建我自己的IMAP圖書館,到目前爲止,我已經能夠做的一切我都試過(連接,登錄,目錄,選擇,獲取等)。IMAP選擇多措辭郵箱
我有問題,但是,在選擇具有在其名稱中多個單詞的郵箱。
例如,郵箱名稱爲「新建標籤」不能,而「INBOX」選擇成功選擇。
0002 LIST "" "%"
* LIST (\HasNoChildren) "/" "INBOX"
* LIST (\HasNoChildren) "/" "New"
* LIST (\HasNoChildren) "/" "New Label"
* LIST (\HasChildren \Noselect) "/" "[Gmail]"
0002 OK Success
0003 SELECT INBOX
0003 OK [READ-WRITE] INBOX selected. (Success)
0004 SELECT New Label
0004 BAD Could not parse command
的IMAP規範(RFC 3501 5.1郵箱命名)不引用應如何處理。它確實提到了國際化命名5.1.3,但它指出US-ASCII可打印字符代表它們自己。
答案this question表明,郵箱名稱應與它的空間被髮送,但是這顯然不是我的情況下工作。
這是我用來創建命令(每到目前爲止,我已經試過命令正常工作)代碼:
public ResponseStatusEnum sendCommandReceiveResponse(out List<String> responseArray, string command, params string[] cmdParams)
{
ResponseStatusEnum response;
if (command == null) throw new Exception("No command passed in to send to the server");
// Increment the id before getting the id string
m_nCommandId++;
StringBuilder sbCommand = new StringBuilder(CommandId + " ");
// Include the Imap command
sbCommand.Append(command);
//Include the parameters specific to the command
for (int i = 0; i < cmdParams.Length; i++)
{
sbCommand.Append(" " + cmdParams[i]);
}
sbCommand.Append(ImapEol);
謝謝,我會確保過詢問更多的問題之前閱讀語法部分。我正在做非常基本的事情(我想熟悉IMAP),所以我決定不去圖書館。 – havan
我以爲你可能會這樣做。您可能會發現Mailkit的源代碼也很有趣,它是C#,寫得很好。 – arnt
Fwiw,MailKit的源代碼可以在https://github.com/jstedfast/MailKit找到。 – jstedfast