解决方案 »

  1.   


     public void SendMail(string formaddr, string formpros, string Encod, string toaddr, string topros, string server, string username, string password, string title, string body)
            {
                MailMessage message = new MailMessage(new MailAddress(formaddr, formpros, Encoding.GetEncoding(Encod)), new MailAddress(toaddr, topros, Encoding.GetEncoding(Encod)));
                SmtpClient client = new SmtpClient(server);
                NetworkCredential credential = new NetworkCredential(username, password);
                message.Subject = title;
                message.Body = body;
                message.BodyEncoding = Encoding.GetEncoding(Encod);
                message.SubjectEncoding = Encoding.GetEncoding(Encod);
                message.IsBodyHtml = true;
                client.Credentials = credential;
                try
                {
                    client.Send(message);
                }
                catch (SmtpFailedRecipientException exception)
                {
                    throw new Exception(exception.Message, exception);
                }
            }