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

posted @ 2021-08-05 11:06  左正  阅读(18)  评论(0编辑  收藏  举报