How to get email from pop.gmail.com using c#?
i want to read email from pop.gmail.com using console application.
Pop3 client = new Pop3();
client.Connect("pop.gmail.com",995);
client.Login("xyz@searce.com", "12345");
//client.IsAuthenticated = true;
// get message list
Pop3MessageCollection list = client.GetMessageList();
if (list.Count == 0)
{
Console.WriteLine("There are no messages in the mailbox.");
}
else
{
// download the first message
MailMessage 开发者_Go百科message = client.GetMailMessage(list[0].SequenceNumber);
}
client.Disconnect();
}
i got error server has closed the connection. i have already disable firewall and antivirus.
plz help me.
You need to connect using SSL. I'm not sure which third-party library you're using (there are dozens, and I imagine at least more than one that uses the class name Pop3
), but you might need to set that explicitly.
According to Gmail, you first need to enable POP. Maybe this will help.
精彩评论