邮箱发邮件

 

  private void FSMail(int num)

        {

            try

            {

                string strSmtpServer = "smtp.163.com";

                string strFrom = "[email protected]";//服务器的邮箱()即本人的

                string strFromPass = "XXXXX";//服务器的密码!

                string strto = this.TextBox4.Text;

                string strSubject = "您注册了京东商城账号";

                string strBody = "恭喜你注册成功,您的用户ID:" + num + ",账号:" + this.TextBox1.Text + ",密码:" + this.TextBox2.Text + ",请用用户ID登录。";

                System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);

                client.UseDefaultCredentials = true;

                client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);

                client.DeliveryMethod = SmtpDeliveryMethod.Network;

 

                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strFrom, strto, strSubject, strBody);

                message.BodyEncoding = System.Text.Encoding.UTF8;

                message.IsBodyHtml = true;

                client.Send(message);

            }

            catch(Exception)

            {

 

            }

        }

 

 

你可能感兴趣的:(邮箱发邮件)