zoukankan      html  css  js  c++  java
  • C# .net 调用QQ邮箱

    public static void QQfs()
            {
                try
                {
                    MailMessage mm = new MailMessage();
                    MailAddress Fromma = new MailAddress("xxxxxx@qq.com");
                    MailAddress Toma = new MailAddress("mmmmmm@qq.com", null);
                    mm.From = Fromma;
                    //收件人
                    mm.To.Add("mmmmmm@qq.com");
                    //邮箱标题
                    mm.Subject = "Hello Dear:";
                    mm.IsBodyHtml = true;
                    //邮件内容
                    mm.Body = "你好Mr流星!";
                    //内容的编码格式
                    mm.BodyEncoding = System.Text.Encoding.UTF8;
                    //mm.ReplyTo = Toma;
                    //mm.Sender =Fromma;
                    //mm.IsBodyHtml = false;
                    mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
                    mm.CC.Add(Toma);
                    SmtpClient sc = new SmtpClient();
                    NetworkCredential nc = new NetworkCredential();
                    nc.UserName = "xxxxxx@qq.com";//你的邮箱地址
                    nc.Password = "xxxxxxxx";//邮箱密码,这里的密码是xxxxx@qq.com邮箱的密码~
                    sc.UseDefaultCredentials = true;
                    sc.DeliveryMethod = SmtpDeliveryMethod.Network;
                    sc.Credentials = nc;
                    //如果这里报mail from address must be same as authorization user这个错误,是你的QQ邮箱没有开启SMTP,
                    //到你自己的邮箱设置一下就可以啦!在帐户下面,如果是163邮箱的话,下面该成smtp.163.com
                    sc.Host = "smtp.qq.com";
                    sc.Send(mm);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
  • 相关阅读:
    模块3 re + 正则表达式
    模块2
    模块1
    super
    MRO,C3算法
    日志,固定格式
    异常处理,MD5
    类的约束
    反射
    异常处理MR5
  • 原文地址:https://www.cnblogs.com/pingming/p/4458002.html
Copyright © 2011-2022 走看看