WebMail发送邮件

MVC提供了WebMail来帮助我们发送邮件,很简单

@{
                WebMail.SmtpServer = "smtp.163.com";          
                WebMail.SmtpPort = 25;           
                WebMail.EnableSsl = false;        
                WebMail.UserName = "username";     
                WebMail.Password = "password";       
                WebMail.From = "username@163.com";
                WebMail.Send("565791254@qq.com","RSVP Notification","廖伟,你快回来");
}

发送附件

var fileAttachment = Request["fileAttachment"];
WebMail.SmtpServer = "smtp.163.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = true;
WebMail.UserName = "username";
WebMail.Password = "password";
WebMail.From = username@163.com;
var filesList = new string[] { fileAttachment };
//多个收件人之间用”,“分隔
WebMail.Send(to: "
3747353312@qq.com,7637044535@qq.com", subject: "TestWebMail", body: "这是test邮件", filesToAttach: filesList);

如果遇到如下问题,检查UserName或者Password是否正确

Tag:多个收件人之间用”,“分隔,在msdn上说的是用”;“分隔,而我用”;“出现

posted on 2013-05-21 14:58  DonnyPeng  阅读(330)  评论(0编辑  收藏  举报