zoukankan      html  css  js  c++  java
  • 发送邮件-成功

    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>");
                }
            }
        }
    }

  • 相关阅读:
    JDK1.8中IndexedPropertyDescriptor的改变对BeanUtils的影响
    tomcat生成ssl证书并发布浏览器信任的https服务
    spring boot问题记录
    阿里云ecs服务器搭建以及polarDB使用说明
    关闭代理后,仍不能正常浏览或使用软件
    python基础-异常介绍
    python基础-中文编码
    python读取Excel,且存入列表中
    短信验证工作流程
    接口自动化测试框架HttpRunner使用案例
  • 原文地址:https://www.cnblogs.com/sntetwt/p/4523507.html
Copyright © 2011-2022 走看看