stringHost =Conf.ConfigInfo.POP_Host; intPort =Conf.ConfigInfo.POP_Port; stringUsername =Conf.ConfigInfo.MailName; stringPassword =Conf.ConfigInfo.MailPassword; using(S22. Imap.imapclient client =NewS22. Imap.imapclient (host, port, username, password)) {varUnseen =client. Search (Searchcondition.unseen (), Conf.ConfigInfo.SelectFolder); if(Unseen = =NULL|| Unseen. Count () = =0) {Console.WriteLine (string. Format ("==============> no new mail! ")); return; } Console.WriteLine (string. Format ("==============> Start Detection")); foreach(UINTUidinchunseen) { varmsg= client. GetMessage (UID,true, Conf.ConfigInfo.SelectFolder); Try{fetchcallback (msg, UID); Client. Setmessageflags (Uid,conf.configinfo.selectfolder,messageflag.seen); } Catch(Exception ex) {Throwex; } } }
var msg= client. GetMessage (Uid,true,conf.configinfo.selectfolder);
Note: The default MSG is to get the text message content to get the HTML content code as follows
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 # uses S22.Imap.dll to receive messages and to specify unread messages for the folders that are received, and to change the unread state