zoukankan      html  css  js  c++  java
  • C#电子邮件

    #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

  • 相关阅读:
    LOL 计蒜客
    cf1486 D. Max Median
    P3567 [POI2014]KUR-Couriers
    dp 求物品组合情况
    黑暗爆炸
    hdu5306 Gorgeous Sequence
    P4609 [FJOI2016]建筑师
    cf 1342 E. Placing Rooks
    重修dp-背包
    acwing 2154. 梦幻布丁
  • 原文地址:https://www.cnblogs.com/skyblue/p/674567.html
Copyright © 2011-2022 走看看