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

  • 相关阅读:
    Tomcat
    二叉树
    CDOJ 1962 天才钱vs学霸周2【最大流】
    次小生成树(POJ1679/CDOJ1959)
    CDOJ1927 爱吃瓜的伊卡洛斯(2) 【并查集】启发式合并+set
    HDU 1074 Doing Homework(DP状态压缩)
    uva 11367 (Dijkstra+DP)
    线段树模板
    openpose pytorch代码分析
    opencv图片坐标和数组下标
  • 原文地址:https://www.cnblogs.com/csnd/p/12062192.html
Copyright © 2011-2022 走看看