Exemplo n.º 1
0
        public void OnSave(object parameter)
        {
            var        passwordBox = (PasswordBox)parameter;
            IMAPClient client      = new IMAPClient(DomainName);

            if (client.Connect(Username, passwordBox.Password))
            {
                MailBoxWindow mailBox = new MailBoxWindow(client);
                App.Current.MainWindow = mailBox;
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            LoginView view = this as LoginView;

            IMAPClient client = new IMAPClient(view.Domain.Text);

            if (client.Connect(view.Username.Text, passwordBox.Password))
            {
                MailBoxWindow mailBox = new MailBoxWindow(client);
                App.Current.MainWindow = mailBox;
            }
        }
Exemplo n.º 3
0
        static void IMAPTest()
        {
            //mailhose host = new mailhose
            //{
            //    server = "imap.163.com",
            //    Ssl = true,
            //    address = "*****@*****.**",
            //    password = "******",
            //    port = 993
            //};

            mailhost host = new mailhost
            {
                server   = "imap.126.com",
                Ssl      = false,
                address  = "*****@*****.**",
                password = "******",
                port     = 110
            };

            using (IMAPClient client = new IMAPClient())
            {
                client.Connect(host.server, host.port, host.Ssl);
                client.Login(host.address, host.password);
                var mailboxlist = client.ListMailbox();
                Console.WriteLine("邮箱列表:");
                Console.WriteLine(mailboxlist);

                client.SelectINBOX();
                MailHeadList list = client.GetMailHeads(SearchType.All);
                foreach (MailHeadModel mailheader in list)
                {
                    Console.WriteLine("UID: " + mailheader.UID);
                    Console.WriteLine("用户名: " + mailheader.Name);
                    Console.WriteLine("地址: " + mailheader.Address);
                    Console.WriteLine("主题: " + mailheader.Subject);
                    Console.WriteLine("日期: " + mailheader.Date.ToString("yyyy-MM-dd"));
                    Console.WriteLine();
                }

                var mailtest = client.GetMail(1);
                Console.WriteLine("UID: " + mailtest.MailHead.UID);
                Console.WriteLine("用户名: " + mailtest.MailHead.Name);
                Console.WriteLine("地址: " + mailtest.MailHead.Address);
                Console.WriteLine("主题: " + mailtest.MailHead.Subject);
                Console.WriteLine("日期: " + mailtest.MailHead.Date.ToString("yyyy-MM-dd"));
                Console.WriteLine("内容: " + mailtest.Body);
                Console.WriteLine();
                Console.WriteLine("超文本内容: " + mailtest.BodyHtml);
                Console.WriteLine("附件:");
                foreach (var item in mailtest.Attachments)
                {
                    //item.Download(@"E:\mailattachments");
                    Console.WriteLine(item.Name);
                }

                client.Disconnect();
                client.Dispose();
            }

            Console.ReadLine();
        }