• 发送邮件-成功


    using System;
    using System.Text;
    using System.Net.Mail;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace Discuz.Web.tools
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Button1_Click(object sender, EventArgs e)
            {
                SmtpClient _smtpClient = new SmtpClient();
                _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
                _smtpClient.Host = "mail.gzmsg.com";//指定SMTP服务器
                _smtpClient.Credentials = new System.Net.NetworkCredential("yxx@gzmsg.com", "yangxiuxu");//用户名和密码

                MailAddress _from = new MailAddress("yxx@gzmsg.com", "杨秀徐");
                MailAddress _to = new MailAddress("471812366@qq.com");
                MailMessage _mailMessage = new MailMessage(_from, _to);
                _mailMessage.Subject = "主题";//主题
                _mailMessage.Body = "内容";//内容
                _mailMessage.BodyEncoding = System.Text.Encoding.Default;//正文编码
                _mailMessage.IsBodyHtml = true;//设置为HTML格式
                _mailMessage.Priority = MailPriority.Normal;//优先级

                try
                {
                    _smtpClient.Send(_mailMessage);
                    Response.Write("<script>alert('发送成功啦')</script>");
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    Response.Write("<script>alert('发送失败啦')</script>");
                }
            }
        }
    }

  • 相关阅读:
    Python--面向对象编程
    Python--私有
    Python--格式化cookie为字典类型
    Python--异常处理
    Python--加密小练习
    bzoj 1774: [Usaco2009 Dec]Toll 过路费
    lougu T7983 大芳的逆行板载
    bzoj 1083(&vijos 1190): [SCOI2005]繁忙的都市 && bzoj 1601: [Usaco2008 Oct]灌水
    vijos 1083 小白逛公园
    51nod 1766 树上的最远点对
  • 原文地址:https://www.cnblogs.com/sntetwt/p/4523507.html
Copyright © 2020-2023  润新知