邮件发送

 public void sendmail(string email,string expense,string name,string remain)

        {

            if (email == string.Empty)

            { return; }

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

            msg.To.Add(email);

            msg.From = new MailAddress("fromclient", "title", System.Text.Encoding.UTF8);

            msg.Subject = 标题;//邮件标题   

            msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码   

            msg.Body =邮件主要内容;//邮件内容   

            msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码   

            msg.IsBodyHtml = false;//是否是HTML邮件   

            msg.Priority = MailPriority.Normal;//邮件优先级 

            SmtpClient client = new SmtpClient();

            client.Credentials = new System.Net.NetworkCredential(“用户名”, “密码”); 

            client.Host = "例如:mail.163.com";

            object userState = msg;

            try

            {

                client.Send(msg);

                 

            }

            catch (System.Net.Mail.SmtpException ex)

            {

                

            }



        }

比较有意思的邮件发送代码

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