zoukankan      html  css  js  c++  java
  • C#-Stmp发邮件

    public MailMessage Initial(string Address)
            {
                MailMessage m_Mail = new MailMessage();
                //发件人
                m_Mail.From = new MailAddress("wawd74520@tom.com");
                //收件人
                m_Mail.To.Add(new MailAddress(Address));
                //主题
                m_Mail.Subject ="代理好久没验证了!!!";
                //内容
                m_Mail.Body = "赶紧重开一下吧!!!";
                //邮件主题和正文编码格式
                m_Mail.SubjectEncoding = System.Text.Encoding.UTF8;
                m_Mail.BodyEncoding = System.Text.Encoding.UTF8;
                //邮件正文是Html编码
                m_Mail.IsBodyHtml = true;
                //优先级
                m_Mail.Priority = System.Net.Mail.MailPriority.High;
                //添加附件,可以添加多个
                //m_Mail.Attachments.Add(new Attachment("f:\1.txt"));
                //密件抄送收件人
                m_Mail.Bcc.Add(Address);
                //抄送收件人
                m_Mail.CC.Add(Address);
    
    
                return m_Mail;
            }
    
    
     private bool SendEmil()
            {
                SmtpClient client = new SmtpClient();
                //这个地方的用户名你可以用split从发送人中截取
                client.Credentials = new System.Net.NetworkCredential("wawd74520", "7452088");
                client.Port = 25;
                client.Host = "smtp.tom.com";
                try
                {
                    client.Send(Initial("1649691481@qq.com"));
                    //ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script>alert('发送成功!')</script>");
                    SuccMsg.Add("发送邮件成功!" + "1649691481@qq.com");
                    return true;
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    SuccMsg.Add("发送邮件失败!" + "1649691481@qq.com");
                    return false;
                }    
            }

  • 相关阅读:
    var 和 let 的区别
    js初步认识变量
    弹性布局
    盒模型
    多重样式优先级深入概念
    层叠机制--比较特殊性
    anroid抓包工具tcpdump的用法
    linux find grep组合使用
    Protect Broadcast 保护广播
    android:exported 属性详解
  • 原文地址:https://www.cnblogs.com/csnd/p/12062192.html
Copyright © 2011-2022 走看看