一个简单的ASP.NET问题,都来抢分吧
我做的网站上面有一个用户忘记密码时找回密码的功能,我想通过让用户在一个文本框里面输入用户名我就把密码通过邮件给他发回去,不知道如何实现发一个邮件,望高手指教.
------解决方案--------------------先抢一个沙发。
------解决方案--------------------web.mail
------解决方案--------------------不知道呢,没做过,可能要在web.config里配好多东东~!
------解决方案--------------------http://www.manbu.net/Lib/Class2/Sub2/1/32.asp
------解决方案--------------------使用SmtpMail类阿
------解决方案--------------------MailMessage email = new MailMessage();
email.To = "xxx@yyy.com ";
email.From = "xxxxxxxxxx ";
email.Subjec = "Test ";
email.Body = "dddddddddd\n\neeeeeeeeeeeeee\n\nfffffffffffffff ";
SmtpMail.Send(email);
------解决方案--------------------用Jmail组件,引用到.net项目里面。
附类:
public class JMail
{
private string _ToEmail;
private string _ToName;
private string _FromEmail;
private string _FromName;
private string _UserName;
private string _Password;
private string _Subject;
private string _Body;
private string _Smtp;
public JMail()
{
}
public string ToEmail
{
get{return _ToEmail;}
set{_ToEmail = value;}
}
public string ToName
{
get{return _ToName;}
set{_ToName = value;}
}
public string FromEmail
{
get{return _FromEmail;}
set{_FromEmail = value;}
}
public string FromName
{
get{return _FromName;}
set{_FromName = value;}
}
public string UserName
{
get{return _UserName;}
set{_UserName = value;}
}
public string Password
{
get{return _Password;}
set{_Password = value;}
}
public string Subject
{
get{return _Subject;}
set{_Subject = value;}
}
public string Body
{
get{return _Body;}
set{_Body = value;}
}
public string Smtp
{
get{return _Smtp;}
set{_Smtp = value;}
}
public bool Send()
{
jmailNET.MessageClass jmail = new MessageClass();
jmail.Charset = "gb2312 ";
jmail.ContentType = "text/html ";
jmail.Logging = false;
jmail.Silent = true;
jmail.Priority = 3;
//发送者Email
jmail.MailServerUserName = _UserName;
jmail.MailServerPassWord = _Password;
jmail.From = _FromEmail;
jmail.FromName = _FromName;
//接收者Email
jmail.AddRecipient(_ToEmail, _ToName, " ");
//Email内容
jmail.Subject = _Subject;
jmail.AppendHTML(_Body);
bool ReturnValue = jmail.Send(_Smtp, false);
jmail.Close();
return ReturnValue;
}
------解决方案--------------------jmail 可收发.