public void supprMailIMAP(string userName, string psw, string service, bool ssl, int port, string mailsupprBegin, string mailsupprEnd)
        {
            IMAP_Client imapc      = loginMail(userName, psw, service, ssl, port);
            var         folderlist = imapc.GetFolders(null);

            imapc.SelectFolder("INBOX");
            var folder = imapc.SelectedFolder;
            var seqSet = IMAP_t_SeqSet.Parse("@begin:@end".Replace("@begin", mailsupprBegin).Replace("@end", mailsupprEnd));
            var items  = new IMAP_t_Fetch_i[]
            {
                new IMAP_t_Fetch_i_Envelope(),
                new IMAP_t_Fetch_i_Uid(),
                new IMAP_t_Fetch_i_Flags(),
                new IMAP_t_Fetch_i_InternalDate(),
                new IMAP_t_Fetch_i_Rfc822()
            };

            try
            {
                imapc.StoreMessageFlags(true, seqSet, IMAP_Flags_SetType.Add, new IMAP_t_MsgFlags(new string[] { IMAP_t_MsgFlags.Deleted }));
            }
            catch
            {
            }
            imapc.Disconnect();
        }
예제 #2
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);
                }
            }
        }
        public void getMailSendImap(string userName, string psw, string service, bool ssl, int port)
        {
            try
            {
                IMAP_Client imapc      = loginMail(userName, psw, service, ssl, port);
                var         folderlist = imapc.GetFolders(null);
                imapc.SelectFolder("Éléments envoyés");
                //imapc.SelectFolder("INBOX");
                var folder = imapc.SelectedFolder;
                var seqSet = IMAP_t_SeqSet.Parse("1:*");
                var items  = new IMAP_t_Fetch_i[]
                {
                    new IMAP_t_Fetch_i_Envelope(),
                    new IMAP_t_Fetch_i_Uid(),
                    new IMAP_t_Fetch_i_Flags(),
                    new IMAP_t_Fetch_i_InternalDate(),
                    new IMAP_t_Fetch_i_Rfc822()
                };

                imapc.Fetch(false, seqSet, items, this.m_pImap_Fetch_MessageItems_UntaggedResponse);
                System.Threading.Thread.Sleep(500);
                DataTable      dtmail           = datalistmail.getInstance().getdtSend();
                SqlDataAdapter adapteremailrecu = CreerDataAdapterFormail("MailSend");
                dtmail.DefaultView.Sort = "maildateTime DESC";
                int tr   = adapteremailrecu.Update(dtmail.Select(null, null, DataViewRowState.ModifiedCurrent));
                int tr12 = adapteremailrecu.Update(dtmail.Select(null, null, DataViewRowState.Added));
                //System.Threading.Thread.Sleep(500);
                imapc.Disconnect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("ErrGetMail:" + ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// Loads IMAP server folders to UI.
        /// </summary>
        private void LoadFolders(IMAP_Client m_pImap)
        {
            IMAP_r_u_List[] folders = m_pImap.GetFolders(null);

            char folderSeparator = m_pImap.FolderSeparator;

            foreach (IMAP_r_u_List folder in folders)
            {
                string[] folderPath = folder.FolderName.Split(folderSeparator);
                Console.WriteLine(folder.FolderName);
                // Conatins sub folders.
                if (folderPath.Length > 1)
                {
                    string currentPath = "";
                    foreach (string fold in folderPath)
                    {
                        if (currentPath.Length > 0)
                        {
                            Console.WriteLine(currentPath, fold);
                            currentPath += "/" + fold;
                        }
                        else
                        {
                            Console.WriteLine(currentPath, fold);
                            currentPath = fold;
                        }
                    }
                }
            }
        }