Example #1
0
        static void SendMail_Example_Extern()
        {
            string text = System.IO.File.ReadAllText(@"D:\project\网络工程与编程实践\1.txt");

            MailUtil.LoginInfo info_smtp = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "smtp.163.com:25"
            };

            MailUtil.MailInfo mail_info = new MailUtil.MailInfo()
            {
                from    = "*****@*****.**",
                to      = "*****@*****.**",
                cc      = "*****@*****.**",
                subject = "test",
                body    = text,
            };

            Int32 result = MailUtil.login_send_mail_extern(info_smtp, mail_info);

            Console.WriteLine(result);

            Console.ReadKey();
        }
Example #2
0
        static void Validate_Example()
        {
            MailUtil.LoginInfo info_smtp
                = new MailUtil.LoginInfo()
                {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "smtp.163.com:25"
                };
            if (MailUtil.validate_account_smtp(info_smtp))
            {
                Console.WriteLine("Succ");
            }
            else
            {
                Console.WriteLine("Fail");
            }

            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };
            if (MailUtil.validate_account_pop3(info_pop3))
            {
                Console.WriteLine("Succ");
            }
            else
            {
                Console.WriteLine("Fail");
            }

            Console.ReadKey();
        }
Example #3
0
        static void Save_Mail()
        {
            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };

            int num = MailUtil.get_num_mails(info_pop3);

            //info_pop3.account = "11";
            Task[] tasks = new Task[num];
            for (uint i = 1; i <= num; i++)
            {
                uint param       = i;
                var  tokenSource = new CancellationTokenSource();
                var  token       = tokenSource.Token;
                tasks[i - 1] = WaitAsync(Task.Factory.StartNew(() =>
                {
                    int r = MailUtil.pull_save_mail(info_pop3, param);
                    if (r != -1)
                    {
                        Console.WriteLine("Receive mail-{0} success", param);
                    }
                    else
                    {
                        Console.WriteLine("Receive mail-{0} fail", param);
                    }
                }), TimeSpan.FromSeconds(3.0));
            }
            Task.WaitAll(tasks, TimeSpan.FromSeconds(4.0)); // wait for 10 seconds
            Console.WriteLine("tasks all completed");
        }
Example #4
0
        static void ReceiveMail_Example()
        {
            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };

            MailUtil.pull_save_mail(info_pop3, 5);

            Console.ReadKey();
        }
Example #5
0
        static void DeleteMail_Example()
        {
            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };

            var result = MailUtil.del_mail(info_pop3, 2);

            Console.WriteLine(result);

            Console.ReadKey();
        }
Example #6
0
        static void GetNumMails_Example()
        {
            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };

            Int32 num = MailUtil.get_num_mails(info_pop3);

            Console.WriteLine(num);

            Console.ReadKey();
        }
Example #7
0
        static void Receive_All_Example()
        {
            MailUtil.LoginInfo info_pop3 = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "pop.163.com:110"
            };
            try
            {
                int num = MailUtil.get_num_mails(info_pop3);
                for (uint i = 1; i <= num; i++)
                {
                    MailUtil.pull_save_mail(info_pop3, i);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("fail, error:" + e.Message);
            }

            Console.ReadKey();
        }
Example #8
0
        static void SendMail_Example()
        {
            MailUtil.LoginInfo info_smtp = new MailUtil.LoginInfo()
            {
                account = "*****@*****.**",
                passwd  = "ybgissocute2020",
                site    = "smtp.163.com:25"
            };

            MailUtil.MailInfo mail_info = new MailUtil.MailInfo()
            {
                from    = "*****@*****.**",
                to      = "*****@*****.**",
                cc      = "*****@*****.**",
                subject = "test",
                body    = "Haha",
            };

            Int32 result = MailUtil.login_send_mail(info_smtp, mail_info);

            Console.WriteLine(result);

            Console.ReadKey();
        }