2014-10-19 44 views
2

我正在嘗試使用Limilabs IMAP庫連接到電子郵件;Limilabs IMAP異常

tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993); 

正常工作;而limilabs IMAP不

using (Imap imap = new Imap()) 
{ 
    imap.Connect("imap.gmail.com", 993); 

給出了異常:

Limilabs.Client.ServerException was unhandled 
    HResult=-2146233088 
    Message=Tried to read a line. No data received. Please make sure that antivirus and firewall software are disabled or configured correctly. 
    Source=Mail 
    StackTrace: 
     at   .() 
     at   .(MemoryStream) 
     at   .() 
     at Limilabs.Client.IMAP.ImapResponse.(Stream) 
     at Limilabs.Client.IMAP.Imap.(ImapResponse) 
     at Limilabs.Client.IMAP.Imap.(String , Boolean) 
     at Limilabs.Client.IMAP.Imap.ReceiveResponse(String tag) 
     at Limilabs.Client.IMAP.Imap.wqf45mzzsju7786nbrb2h8aclqm8jmnx    () 
     at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL) 
     at Limilabs.Client.ClientBase.Connect(String host, Int32 port) 
     at ConsoleIMAP.Program.Main(String[] args) in c:\users\hmohamed\WcfServiceLibrary1\ConsoleIMP\Program.cs:line 136 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: 
     HResult=-2146233088 
     Message=Tried to read a line. No data received. 
     Source=Mail 
     StackTrace: 
      at   .() 
     InnerException: 
+0

讓我猜猜,Limilabs預計不使用TLS說話IMAP,Gmail的IMAP預計使用TLS,並因此他們沒有給對方說話過? – arnt 2014-10-20 07:23:57

+0

所以我可以嘗試hotmail! – kobosh 2014-10-20 15:10:56

+0

嘗試connectssl,但它超時 – kobosh 2014-10-20 16:39:21

回答

0

我知道這個問題爲2歲,但它可能是別人有這個問題很重要。

Imap.Connect/Imap.ConnectSSL方法不僅連接,他們也開始TLS/SSL協議(如果需要),得到初步的服務器響應,並獲得通過IMAP服務器支持的擴展。

這就是爲什麼與TcpClient的連接可能看起來像它的工作在第一,但事實上,你還沒有開始TLS/SSL協商,也不與服務器的任何其他通信。

的Gmail只支持TLS/SSL連接,所以你必須使用ConnectSSL方法,也沒有必要明確指定端口:

using (Imap imap = new Imap()) 
{ 
    imap.ConnectSSL("imap.gmail.com"); 

    //... 

    imap.Close() 
} 

請記住,必須enable IMAP access for your account in Gmail