码迷,mamicode.com
首页 > 其他好文 > 详细

邮件发送

时间:2016-06-24 23:37:45      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

public ActionResult Index()
{
    MailMessage mailMessage = new MailMessage();//导入system.net这个Assembly
    mailMessage.From = new MailAddress("发件人邮箱地址","我是谁");
    mailMessage.To.Add(new MailAddress("收件人邮箱地址", "我是一个好人"));//可以有多个收件人发件人邮箱地址
    mailMessage.Subject = "这是邮件标题";
    mailMessage.Body = "<a href=‘http://www.baidu.com‘>测试页面</a>";
    mailMessage.IsBodyHtml = true;
    //mailMessage.Bcc = "";
    //mailMessage.CC = "";
    //mailMessage.From;
    //mailMessage.To;
    //mailMessage.Sender;
    //mailMessage.IsBodyHtml = true;
    //指定SMTP服务地址
    SmtpClient client = new SmtpClient("smtp.163.com");
    client.Credentials = new NetworkCredential("发件人邮箱名称", "发件人邮箱密码");
    client.Send(mailMessage);
    return Content("发送成功");
}

 

邮件发送

标签:

原文地址:http://www.cnblogs.com/genesis/p/5615558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!