.net 发送邮件验证码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
using System.Web.Mvc;

namespace SXDroughtWeb.Controllers
{
public class MailController : Controller
{
//
// GET: /Mail/

public void sm1()
{
for (int i = 1; i <= 10; i++)
{
MailMessage mailObj = new MailMessage();
mailObj.From = new MailAddress("mr@163.com"); //发送人邮箱地址
mailObj.To.Add("2559@qq.com"); //收件人邮箱地址
mailObj.Subject = "001"; //主题
mailObj.Body = "123"; //正文
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.163.com"; //smtp服务器名称
smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential("mr", "a13"); //发送人的登录名和密码
smtp.Send(mailObj);
}
}
}
}

posted @ 2017-02-14 17:07  大鹅先生  阅读(262)  评论(0编辑  收藏  举报