. Net c # Use S22.Imap. dll to receive mails and specify the unread mails in the folder to be received, and change the unread quasi-State,
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. W RiteLine (string. Format ("================> no new email! "); Return;} Console. writeLine (string. format ("================> start detection"); 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);
Note: by default, MSG is the obtained TEXT mail content. The code for obtaining HTML content is 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 ));