日期:2014-05-18  浏览次数:20517 次

谁能告诉我这个怎么实现啊?问题搞定了就散分,在线等,求高手帮忙!!!
实现一个用户订阅邮件的场景
描述:
1.用户使用邮件来注册
2.系统在5分钟内发送激活链接的邮件
3.用户点击邮件后,激活用户,结束
4.管理员可以查看已经激活和未激活的用户列表
5.无需实现用户登录

使用asp.net   2.0
使用C#语言

希望高手看见能给予回答或提示怎么做,有原代码提供就更好了
或发送邮件到accp2003@163.com



------解决方案--------------------
呵呵
我的意思是 总体的需求你要自己考虑 要源代码对你也没有什么提高的

下面是.NET里面发送邮件的代码,不过你要指定一个SMTP服务器,可以把你OUTLOOK里面的STMP服务器用上

/// <summary>
/// 发送邮件
/// </summary>
public static bool SendEmail(string server, int port, string user, string pass,
MailAddress to, MailAddress from, string subject, string body, bool isHtml)
{
System.Net.Mail.SmtpClient client = new SmtpClient(server, port);
client.Credentials = new System.Net.NetworkCredential(user, pass);
client.DeliveryMethod = SmtpDeliveryMethod.Network;//指定发送方式 Network是直接用smtp发送

MailMessage message = new MailMessage(from, to);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = isHtml;
message.BodyEncoding = message.SubjectEncoding = System.Text.Encoding.GetEncoding( "gb2312 ");
client.Send(message);
return true;
}
------解决方案--------------------
private void SendMail(string from, string to, string subject, string body)
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient( "10.40.11.1 ");
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential();
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
string sendstate = " ";

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, to, subject, body);
client.SendCompleted += new System.Net.Mail.SendCompletedEventHandler(client_SendCompleted);
//client.SendAsync(msg, sendstate);//*
client.Send(msg);
}

private void client_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
// Get the unique identifier for this asynchronous operation.
String token = (string)e.UserState;

if (e.Cancelled)
{
Console.WriteLine( "[{0}] Send canceled. ", token);
}
if (e.Error != null)
{
Console.WriteLine( "[{0}] {1} ", token, e.Error.ToString());
}
else
{
Console.WriteLine( "Mail Send Success! ");
}

}


////发送邮件有同步和异步两种方法,异步程序响应快,但是邮件不一定可以及时被发出,同步程序相应速度慢,但是有邮件什么时候发出去,程序员是可知的。如果需要异步发送,把打上 "* "的一行注释去掉,把下一行注释掉就可以了。


只要发送一个激活码串就可以了,可以使用GUID,也可以用你自己的算法生成。比如
http://www.abc.com/activate.aspx?code=49dfg030s0394x&username=helloworld
activate文件只要从数据库中比对helloworld对应的code就可以设置用户表中helloworld用户的相应字段为true或者false了。
------解决方案--------------------
1 首先用户输入邮箱提交时,记录在数据库,并记录该状态为 "未激活 ".
2 系统给该邮箱发送一份带有加密参数的URL(发送邮件和加密我就不说了,网上多的是).
3 当用户点击邮件里面的URL时,系统解析参数,正确的话让用户处于登陆状态,同时更改数据库激活状态.
------解决方案--------------------
发送邮件给用户,

邮件的内容用html格式编写一个网页链接 也就是 <a href= " "> </a> ,你做一个网页与之对应,,