读者朋友:
您好,将头部的System.Web.Mail命名空间修改为System.Net.Mail命名空间,然后将发送邮件的代码修改如下:
//创建MailMessage对象
MailMessage myEmail = new MailMessage();
//设置发件人地址
myEmail.From = new MailAddress("xiaoyu@mr.com");
//设置收件人地址
myEmail.Sender=new MailAddress( email);
//设置邮件主题
myEmail.Subject = subject;
//设置邮件内容
myEmail.Body = body;
//设置邮件正文类型
myEmail.BodyEncoding = System.Text.Encoding.UTF8;
//设置服务器名
SmtpClient smtp = new SmtpClient("MRSY");
//发送电子邮件
smtp.Send(myEmail);