Net Core教程

C#实现监听网易邮箱

本文主要是介绍C#实现监听网易邮箱,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

要用到 S22.Imap 一个开源的动态库

string host = "网易收件服务器";
int port = 993;//用的qq邮箱发的端口是993 网易的是995 监听网易邮箱要监听993端口
string username = "账号";
string password = "密码";

using (ImapClient client = new ImapClient(host, port, username, password, AuthMethod.Login, true))
{

IEnumerable<uint> uids = client.Search(SearchCondition.Unseen());
// Download mail messages from the default mailbox.
IEnumerable<MailMessage> messages = client.GetMessages(uids, FetchOptions.HtmlOnly);
foreach (var item in messages)
{
string From = item.From.ToString();
string Body = item.Body.ToString();
string Subject = item.Subject.ToString();
}


}

就是这么简单

Github地址:https://github.com/yuzd/S22.Imap

这篇关于C#实现监听网易邮箱的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!