예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                //smtp.163.com
                //string senderServerIp = "123.125.50.134";

                const string senderServerIp = "smtp.163.com";

                //smtp.gmail.com
                //string senderServerIp = "74.125.127.109";
                //smtp.qq.com
                //string senderServerIp = "58.251.149.147";
                //string senderServerIp = "smtp.sina.com";
                string toMailAddress   = "*****@*****.**";
                string fromMailAddress = "*****@*****.**";
                string subjectInfo     = "Test sending e_mail";
                string bodyInfo        = "Hello Eric, This is my first testing e_mail";
                string mailUsername    = "******";
                string mailPassword    = "******"; //发送邮箱的密码()
                string mailPort        = "25";
                string attachPath      = "D:\\BugReport.txt; D:\\docs\\行情展示.png";

                var email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo,
                                        mailUsername, mailPassword, mailPort, false, false);
                email.AddAttachments(attachPath);
                email.Send();

                Thread.Sleep(10000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
예제 #2
0
        public static void SendMail(string subjectInfo   = "Test sending e_mail",
                                    string bodyInfo      = "Hello Eric, This is my first testing e_mail", bool isMailingEnabled = true,
                                    string attachedFiles = null)
        {
            try
            {
                if (isMailingEnabled)
                {
                    const string senderServerIp = "smtp.163.com";

                    string toMailAddress   = "*****@*****.**";
                    string fromMailAddress = "*****@*****.**";
                    string mailUsername    = "******";
                    string mailPassword    = "******"; //发送邮箱的密码()
                    string mailPort        = "25";

                    var email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo,
                                            mailUsername, mailPassword, mailPort, false, false);

                    if (!string.IsNullOrEmpty(attachedFiles))
                    {
                        email.AddAttachments(attachedFiles);
                    }

                    email.Send();
                }
            }
            catch (Exception ex)
            {
                Utils.WriteException(ex);
            }
        }
예제 #3
0
        public static void SendMail(string subjectInfo   = "Test sending e_mail",
                                    string bodyInfo      = "Hello Eric, This is my first testing e_mail", bool isMailingEnabled = true,
                                    string attachedFiles = null)
        {
            try
            {
                if (isMailingEnabled)
                {
                    const string senderServerIp = "smtp.163.com";

                    string toMailAddress   = "*****@*****.**";
                    string fromMailAddress = "*****@*****.**";
                    string mailUsername    = "******";
                    string mailPassword    = "******"; //发送邮箱的密码()
                    string mailPort        = "25";

                    var email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo,
                                            mailUsername, mailPassword, mailPort, false, false);

                    if (!string.IsNullOrEmpty(attachedFiles))
                    {
                        email.AddAttachments(attachedFiles);
                    }

                    email.Send();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }