zoukankan      html  css  js  c++  java
  • ASP.NET2.0发送邮件实例

    以前写过1.1的代码,那是用System.web.mail,可是以前的写法在2005里面会警告了。不爽,改成2.0的写法,需要using System.Net.Mail。代码如下:

                System.Net.Mail.MailMessage mailObj = new System.Net.Mail.MailMessage();
                mailObj.IsBodyHtml = true;
                mailObj.Subject = "Test ASP.Net2.0 Mail";
                mailObj.Body = "You did a good job.";
                mailObj.To.Add("vs.net2003@hotmail.com");
                System.Net.Mail.SmtpClient SmtpMail = new SmtpClient("smtp.sina.com.cn");
                mailObj.From = new MailAddress("liujt119@sina.com.cn", "Catvi", System.Text.Encoding.UTF8);
                SmtpMail.Credentials = new System.Net.NetworkCredential("liujt119@sina.com.cn", "××××××");
                SmtpMail.Send(mailObj);

    ×××××× 是你的账户密码,对应修改。

  • 相关阅读:
    跨域问题注解解决
    跳出循环到指定位置
    idea model管理
    maven 取本地jar
    注解 元注解
    手动打jar包到maven
    sonar搭建
    jmockit、junit
    注解
    虚拟机指令
  • 原文地址:https://www.cnblogs.com/catvi/p/1952974.html
Copyright © 2011-2022 走看看