zoukankan      html  css  js  c++  java
  • 用.NET提供的Mail来发邮件

     首先添加:using System.Net.Mail;

     代码如下,具体自己处理,以符合你的需求:

      public static bool SendMail(string subject, string body)
       {
                bool result = false;
                try
                {

                        List<string> toMailList =new List<string>(){

                        {"sping@sina.com"},

                        {"springyang@sina.com"}

                        };

                        if (toMailList.Count > 0)
                        {
                            MailMessage mail = new MailMessage();
                            foreach (string address in toMailList)
                            {
                                mail.To.Add(new MailAddress(address));
                            }
                            mail.From = new MailAddress("sping1@sina.com");
                            mail.Subject = subject;
                            mail.Body = body;
                            mail.BodyEncoding = System.Text.Encoding.UTF8;
                            mail.IsBodyHtml = false;
                            SmtpClient client = new SmtpClient();
                            client.Host = 25;
                            client.Port = Convert.ToInt32("8080");
                            client.EnableSsl = True;
                            client.Send(mail);
                            result = true;
                        }
                   
                }
                catch (Exception ex)
                {
               
                }
                return result;
            }

  • 相关阅读:
    Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理
    Codeforces Round #279 (Div. 2) A. Team Olympiad 水题
    Codeforces Round #279 (Div. 2) B
    利用Hog特征和SVM分类器进行行人检测
    opencv 支持向量机SVM分类器
    opencv hog算子
    NOIP 2008 传纸条 NOIP 2000 方块取数 多线程DP
    POJ 1654 Area 计算几何
    hihocoder #1015 KMP
    HDU 1722 Cake 数学题
  • 原文地址:https://www.cnblogs.com/springyangwc/p/1961274.html
Copyright © 2011-2022 走看看