-1

I am trying to retrieve mails on my Yahoo account using C#. I tested OpenPop to do that I write that

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());

The problem that the server always did not accept user credentials but I'm sure the credentials are OK.

I tried the same code with my gmail account and every thing goes ok is something missing Yahoo want me to set it?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    _"the server always did not accept user credentials"_ - what's the **exact** error? – CodeCaster Jun 28 '12 at 11:11
  • Server did not accept user credentials --- this is error message that I getting – user1369192 Jun 28 '12 at 11:14
  • @weismat the third argument to [`Connect()`](http://hpop.sourceforge.net/documentation/OpenPop~OpenPop.Pop3.Pop3Client.Connect2.html) states he's using SSL. – CodeCaster Jun 28 '12 at 11:15
  • @user1369192 does it work in a mail client like Outlook or Thunderbird? Are you supplying the correct User ID? The [manual](http://help.yahoo.com/kb/index?page=content&y=PROD_MAIL_CLASSIC&locale=en_US&id=SLN3213) states: _"Please note: Your ID is typically your email address without the "@yahoo.com";"_ – CodeCaster Jun 28 '12 at 11:16
  • I tried , without using "@yahoo.com " . still it is not working. getting the same error Also for the above code it is enabled SSL objClient.Connect( server, port, SSL ( true/ false); – user1369192 Jun 28 '12 at 11:19

2 Answers2

1

In order to access Yahoo mail via an email program you will need to be a Yahoo Mail Plus subscriber.

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.
Otto Kanellis
  • 3,629
  • 1
  • 23
  • 24
0

Try following code:

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

    pop3Client.Connect("pop.mail.yahoo.com", 995, true);
    pop3Client.Authenticate("your@yahoo.com", "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");
}
mrd
  • 2,095
  • 6
  • 23
  • 48
  • this is waht I was wrote. But I need solution for . If have solution it is more helful. I am in a critical situation – user1369192 Jun 28 '12 at 18:57