2015-11-02 71 views
0

我發現了一個ImapProtocolException一條消息:Mailkit取「意外令牌IMAP響應:QString的:‘多部分消息’]」

"Unexpected token in IMAP response: [qstring: "Multipart message"]" when issuing zInbox.Fetch(uids, MailKit.MessageSummaryItems.UniqueId Or MailKit.MessageSummaryItems.BodyStructure Or MailKit.MessageSummaryItems.Envelope) 

但在另一方面,如果我用的GetMessage (uids)一切順利,沒有錯誤。

這裏是ProtocolLogger(你可以看到不獲取完成消息):

C: A00000790 UID FETCH 97824 (UID ENVELOPE BODYSTRUCTURE) 
S: * 24320 FETCH (UID 97824 ENVELOPE ("Mon, 26 Oct 2015 16:48:44 +0000" "NFe" ((NIL NIL "fatsc" "makrocentral.com.br")) NIL NIL ((NIL NIL "fiscal" "generale.ind.br")) NIL NIL NIL "<[email protected]>") BODYSTRUCTURE (("text" "plain" ("charset" "ISO-8859-1") NIL "Message text" "Quoted-printable" 227 8 NIL ("inline" NIL) NIL NIL)("application" "octet-stream" ("name" "42151000460986000506550040000387401000387404-nfe.xml") NIL "Attached file: 42151000460986000506550040000387401000387404-nfe.xml" "Base64" 11086 NIL ("attachment" ("filename" "42151000460986000506550040000387401000387404-nfe.xml")) NIL NIL)("application" "pdf" ("name" "42151000460986000506550040000387401000387404-nfe.pdf") NIL "Attached file: 42151000460986000506550040000387401000387404-nfe.pdf" "Base64" 50364 NIL ("attachment" ("filename" "42151000460986000506550040000387401000387404-nfe.pdf")) NIL NIL) "mixed" ("boundary" "017AC96C_005ED075_Synapse_boundary") "Multipart message" NIL)) 

當使用的GetMessage信息(UID),Protocologger給我一個有趣的信息:

S: X-mailer: Synapse - Pascal TCP/IP library by Lukas Gebauer 

使用其他庫時,我已經遇到了這個郵件程序的問題。

據我瞭解「取」屬於MailKit「的GetMessage」屬於MimeKit

那麼,是否有任何解決方法繼續而不是使用GetMessage? 循環〜1500郵件和下載每一個只是爲了獲取附件名稱需要很長時間?

有沒有人在這裏有類似的郵件這樣的問題「Synapse - Lukas Gebauer的Pascal TCP/IP庫」

+0

jstedfast 有趣.... 在這兩種情況下,使用另一個lib,現在使用MailKit,IMAP服務器是Exchange 2007和Exchange 2013(在Office 365中使用)。 這種情況只發生在使用Synapse的信息範圍爲300k的情況下。 是否有任何其他信息可以幫助我們進一步瞭解?如果消息仍然存在,我可以嘗試。 會很好用Fetch,並繞過預期,儘快它連接迷路。因此,重新開始。 – jzero

回答

1

問題在於IMAP服務器響應了完全中斷的響應。

按照IMAP規範,繼"mixed"令牌多語法應該是:

body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 
       [SP body-fld-loc *(SP body-extension)]]] 
       ; MUST NOT be returned on non-extensible 
       ; "BODY" fetch 
body-fld-param = "(" string SP string *(SP string SP string) ")"/nil 
body-fld-dsp = "(" string SP body-fld-param ")"/nil 
body-fld-lang = nstring/"(" string *(SP string) ")" 
body-fld-loc = nstring 

,但我們得到的是:("boundary" "017AC96C_005ED075_Synapse_boundary") "Multipart message" NIL)

這基本上分解爲以下類型的標記:

body-fld-param [SP] string [SP] nil 

請注意"Multipart message"不允許使用。什麼應該在那裏可以是一個NIL或類似的東西:("inline" ("name" "value"))

換句話說,你的IMAP服務器沒有講話語法正確IMAP。 MailKit無法理解你的IMAP服務器試圖說什麼。

注意:問題在於IMAP服務器,而不是本例中的Synapse Mailer。

+0

我很好奇MIME看起來像什麼導致IMAP服務器如此糟糕。 – Max

+0

我會嘗試獲取更多信息 – jzero