zoukankan      html  css  js  c++  java
  • asp.net发送邮件功能

      /// <summary>
            /// 发送邮箱163
            /// </summary>
            /// <param name="MailFrom">邮箱用户名</param>
            /// <param name="MailTo">接收人用户名</param>
            /// <param name="MailPwd">邮箱用户密码</param>
            /// <param name="Mailtitle">邮件标题</param>
            /// <param name="MailCon">邮件内容</param>
            public void MailSend(string MailFrom, string MailTo, string MailPwd, string Mailtitle, string MailCon)
            {
                MailMessage MyMail = new MailMessage();
                MyMail.From = new MailAddress(MailFrom + "@163.com", "");
                MyMail.To.Add(new MailAddress(MailTo));
                MyMail.Subject = Mailtitle;
                MyMail.SubjectEncoding = System.Text.Encoding.UTF8;
                MyMail.Body = MailCon;
                MyMail.BodyEncoding = System.Text.Encoding.UTF8;
                MyMail.IsBodyHtml = false;
                SmtpClient smtp = new SmtpClient();
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.Host = "smtp.163.com";
                smtp.Credentials = new System.Net.NetworkCredential(MailFrom, MailPwd);
                smtp.Send(MyMail);
            }

    以上代码是可以运行的本人以测试过

  • 相关阅读:
    Vue 服务器端渲染(一)
    vue笔记 介绍及安装 一
    Node.js 学习笔记 (一) 安装配置
    Java开发中的23种设计模式详解(转)
    spring-boot整合ehcache实现缓存机制
    STM32流水灯
    SD卡封转及管脚说明
    随笔分类
    函数的设计之我见
    让灵魂追得上我们疲惫的身体
  • 原文地址:https://www.cnblogs.com/yshj/p/1872165.html
Copyright © 2011-2022 走看看