Sanjay
Sanjay

Reputation: 301

Unable to Connect/Read Outlook 365 Mail Business Account with Pop3Client c#, even correct credentials

Unable to connect Outlook 365 account for reading mails using Pop3Client C# library, receiving error The server did not respond with a + response. The response was: -ERR Logon failure: unknown user name or bad password.Server did not accept user credentials. I'm using below code for connecting Outlook accout.

 MailBox mailBox = new MailBox(emailId, password);
            Pop3Client pop3Client;
            foreach (Credential credential in mailBox.mailBoxList)
            {
                pop3Client = new Pop3Client();
                Console.WriteLine("Connecting to POP.......");
                pop3Client.Connect("outlook.office365.com", 995, true);
                Console.WriteLine("POP Connected.......");
                Console.WriteLine("Authenticating Email......." + credential.EmailId);
                //pop3Client.Authenticate(credential.EmailId, credential.Password); //I have tried without AuthenticationMethod type
                pop3Client.Authenticate(credential.EmailId, credential.Password, AuthenticationMethod.UsernameAndPassword);
                Console.WriteLine("Authentication Done.......");
                if (pop3Client.Connected == true)
                {
                    //TO DO Code
                }
            }

Upvotes: 1

Views: 2384

Answers (1)

Sanjay
Sanjay

Reputation: 301

Follow the below steps to solve this problem (outlook 365 Account).

  1. First change the password.
  2. First, disable & enable the POP and IMAP setting under the sync email tab (setting).

here is screenshot of step 2

Upvotes: 1

Related Questions