C# Use Pop3Client to read gmail

host = "pop.gmail.com"

user = "xxxxx@gmail.com"

password = "xxxx"

port = 995

Pop3Client client = new Pop3Client();

client.connet(host, port, true);

client.Authenticate(user, password, AuthenticationMethod.UsernameAndPassword);

int mailCount = client.GetMessageCount();

在執行authentication時出現exception, InvalidLoginException

解決方法參考 : https://github.com/foens/hpop/issues/39

1-enable the pop at Configurations / Forwarding and POP/IMAP
2- follow this link: https://www.google.com/settings/security/lesssecureapps
and activate for less secure apps. (set [turn on])

 

posted @ 2015-09-26 13:14  日光之下无新事  阅读(356)  评论(0编辑  收藏  举报