C#邮箱发送

        public static void SendTo(string mailAddress, string subject, string body)
        {

   //mailAddress 所要发送的邮箱地址,subject 邮件标题,body邮件内容

    //发送邮件所用邮箱(163邮箱)

    string Email_Send = Dsis.Core.SysCore.PubFunction.DataFilter(Dsis.Core.SysCore.SysFunction.GetParameterInfo("Email_Send")["PValue"]);

    //发送所用邮箱密码

            string Email_Password = Dsis.Core.SysCore.PubFunction.DataFilter(Dsis.Core.SysCore.SysFunction.GetParameterInfo("Email_Password")["PValue"]);
            MailMessage message = new MailMessage();

            message.From = new MailAddress(Email_Send, "发信人", System.Text.Encoding.UTF8);

    //被发送邮箱

            message.To.Add(new MailAddress(mailAddress));

   //邮件标题

            message.Subject = subject;

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

    //邮件内容
            message.Body = body;
            message.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient("smtp.163.com");

   //所用邮箱和密码

            client.Credentials = new NetworkCredential(Email_Send, Email_Password);
            client.EnableSsl = true; //必须经过ssl加密 
            try
            {
                client.Send(message);
            }
            catch (Exception ee)
            {
                ShowMsg(ee.ToString());
            }
        }
        static void ShowMsg(string msg)

        { }

你可能感兴趣的:(C#)