标签:
string host = Conf.ConfigInfo.POP_Host; int port = Conf.ConfigInfo.POP_Port; string username =Conf.ConfigInfo.MailName; string password = Conf.ConfigInfo.MailPassword; using (S22.Imap.ImapClient client = new S22.Imap.ImapClient(host, port, username, password)) { var unseen = client.Search(SearchCondition.Unseen(), Conf.ConfigInfo.SelectFolder); if (unseen == null || unseen.Count() == 0) { Console.WriteLine(string.Format("==============>没有新邮件!")); return; } Console.WriteLine(string.Format("==============>开始检测")); foreach (uint uid in unseen) { var msg= client.GetMessage(uid,true,Conf.ConfigInfo.SelectFolder); try { Fetchcallback(msg, uid); client.SetMessageFlags(uid,Conf.ConfigInfo.SelectFolder,MessageFlag.Seen); } catch (Exception ex) { throw ex; } } }
var msg= client.GetMessage(uid,true,Conf.ConfigInfo.SelectFolder);
注:默认 MSG 是获取的TEXT 邮件内容要获取HTML内容代码如下
var dataStream = msg.AlternateViews[0].ContentStream;
byte[] byteBuffer = new byte[dataStream.Length];
string altbody = msg.BodyEncoding.GetString(byteBuffer, 0, dataStream.Read(byteBuffer, 0, byteBuffer.Length));
.NET C# 使用S22.Imap.dll接收邮件 并且指定收取的文件夹的未读邮件,并且更改未读准态
标签:
原文地址:http://www.cnblogs.com/sunkaixuan/p/4482167.html