2012-06-28 155 views
-1

我試圖使用C#檢索我的雅虎帳戶上的郵件。我測試OpenPop這樣做,我寫使用C#檢索Yahoo電子郵件詳細信息

Pop3Client objClient = new Pop3Client(); 
objClient.Connect("pop.mail.yahoo.com", 995, true); 
objClient.Authenticate("username","pass",AuthenticationMethod.UsernameAndPassword); 
int msgCount = objClient.GetMessageCount(); 
MessageBox.Show(msgCount.ToString()); 

服務器始終不接受用戶憑據,但我敢肯定的憑據是OK的問題。

我用我的Gmail帳戶試過相同的代碼,並且每件事情都可以確定缺少雅虎想要我設置的東西嗎?

+1

_「服務器始終不接受用戶憑證」_ - **確切**錯誤是什麼? – CodeCaster

+0

我想你需要添加SSL。 – weismat

+0

服務器不接受用戶憑證---這是錯誤消息,我得到 – user1369192

回答

0

嘗試下面的代碼:

try 
{ 
    if (pop3Client.Connected) 
     pop3Client.Disconnect(); 

    pop3Client.Connect("pop.mail.yahoo.com", 995, true); 
    pop3Client.Authenticate("[email protected]", "yourpassword"); 
    int count = pop3Client.GetMessageCount(); 
} 
catch (InvalidLoginException) 
{ 
    //MessageBox.Show(this, "The server did not accept the user credentials!", "POP3 Server Authentication"); 
} 
catch (PopServerNotFoundException) 
{ 
    //MessageBox.Show(this, "The server could not be found", "POP3 Retrieval"); 
} 
catch (PopServerLockedException) 
{ 
    //MessageBox.Show(this, "The mailbox is locked. It might be in use or under maintenance. Are you connected elsewhere?", "POP3 Account Locked"); 
} 
catch (LoginDelayException) 
{ 
    //MessageBox.Show(this, "Login not allowed. Server enforces delay between logins. Have you connected recently?", "POP3 Account Login Delay"); 
} 
catch (Exception e) 
{ 
    //MessageBox.Show(this, "Error occurred retrieving mail. " + e.Message, "POP3 Retrieval"); 
} 
+0

這是我寫的,但我需要的解決方案,如果有解決方案,它更加快速。我處於危急的境地 – user1369192

1

爲了通過電子郵件程序,你將需要一個雅虎郵箱用戶加訪問雅虎郵箱。

1. Sign in to Yahoo Mail. 
2. Move your cursor over the gear icon (Gear Icon) and select Mail Options. 
3. Select POP & Forwarding. 
- The "Access your Yahoo Mail elsewhere" option displays. 
4. Select the radio button next to Access Yahoo Mail via POP. 
5. Click Save. 
相關問題