Exemplo n.º 1
0
        public void functionIMAP()
        {
            using (IMAP_Client c = new IMAP_Client())
            {
                try
                {
                    //连接IMAP_Client服务器
                    c.Connect("outlook.office365.com", 993, true);
                    //验证用户身份
                    c.Login(UserName, Pwd);  //邮件密码/smtp、pop3授权码

                    //MessageBox.Show("数量:" + c.GetFolders(null).ToList().Count().ToString());
                    c.GetFolders(null).ToList().ForEach(f => {
                        Console.WriteLine(f.FolderName);
                        var s = c.FolderStatus(f.FolderName);
                        s.ToList().ForEach(sIt => {
                            MessageBox.Show(string.Format("总数:{0},未读:{1},最近{2}", sIt.MessagesCount, sIt.MessagesCount, sIt.UnseenCount));
                        });
                    });
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }