1

I am using openPop library to connect to email and fetch using my c# code.

I am able to fetch mails from gmail account by providing the server details as hostname : "pop.gmail.com" , port : 995 ,SSL : true insdide client.connect() method.Followed by calling client.Authenticate("recent:" + userName, password, AuthenticationMethod.UsernameAndPassword). But when I try to access outlook mail, after changing the credentials am unable to connect.Below is the code that I use for connecting for gmail and outlook respectively.

//gmail connection

        var client = new Pop3Client();

        using (Pop3Client client2 = new Pop3Client())
        {
            // Connect to the server
            client.Connect("pop.gmail.com", 995, true);
            client.Authenticate("recent:" + userName, password, 
            AuthenticationMethod.UsernameAndPassword);
        }

//outlook connection

        var client = new Pop3Client();

        using (Pop3Client client2 = new Pop3Client())
        {
            // Connect to the server
            client.Connect("outlook.office365.com", 995, true);

            client.Authenticate("recent:" + userName, password, AuthenticationMethod.UsernameAndPassword);

}

I am getting a an error on using outlook credentials as below: PopServerException: The server did not respond with a + response. The response was: "-ERR Logon failure: unknown user name or bad password." I have also enabled inside outlook settings Under POP and IMAP, as Yes under Let devices and apps use POP.

Swaroop
  • 501
  • 5
  • 18
  • What is the purpose of this "recent:" stuff? Also, please [edit] your question to include a [mcve] which can be compiled and tested by others, which shows the error messge you get, but would work with other hosts. – Progman Dec 20 '18 at 13:25
  • It is used to read mails along with attachments. – Swaroop Dec 21 '18 at 05:47
  • Can you add the link to the documentation, where it talks about the "recent:" stuff being used in the `Authenticate()` method as the username? Having "recent:" as part of the username looks very wrong. – Progman Dec 21 '18 at 09:50

0 Answers0