文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>用.NET提供的Mail来发邮件

用.NET提供的Mail来发邮件

时间:2011-02-22  来源:spring yang

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

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

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

                    {"[email protected]"},

                    {"[email protected]"}

                    };

                    if (toMailList.Count > 0)
                    {
                        MailMessage mail = new MailMessage();
                        foreach (string address in toMailList)
                        {
                            mail.To.Add(new MailAddress(address));
                        }
                        mail.From = new MailAddress("[email protected]");
                        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;
        }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载