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.