#region 电子邮件
    public static bool  webMail(string host, int port, string uid, string pwd, bool ssl, string from, string to, string subject, string body)
    {
        //string str="成功";
        System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();
        mail.Host = host;
        mail.Port = port;
        mail.Credentials = new System.Net.NetworkCredential(uid, pwd);
        mail.EnableSsl = ssl;
        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);
        message.Body = body;
        message.Subject = subject;
        message.SubjectEncoding = System.Text.Encoding.GetEncoding("gb2312");
        message.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
        message.IsBodyHtml = true;
        try
        {
            mail.Send(message);
            message.Dispose();
            return true;
            //return str;
        }
        catch (Exception ex)
        {
            message.Dispose();

           return false;
           //return ex.ToString();
        }
    }
    #endregion

相关文章:

猜你喜欢
  • 2021-11-02
  • 2022-02-19
  • 2022-12-23
  • 2021-08-16
  • 2021-09-05
  • 2021-11-29
相关资源
相似解决方案