1.数据库加两个字,state字段(0:未激活,1:激活成功),ActiCode:(放激活码)
2.用户填写资料,插入数据成功,state字段默认是0,同时生成一个ActiCode也存入数据库
3.提示用户激活。。。发送邮件。。。邮件中带一个激活成功页的URL,URL里有两个参数(1,用户ID,2:激活码)
4.用户点击链接,回到激活成功页。。。激活成功页的Load事件,得到两个参数,以这两个参数为条件查询数据库里的数据,如果有,修改字段state为1,反之。。提示激活失败,重新激活。。
//这是发送邮件的
//Body里放A标签(前提是IsBodyHtml 设为true,才会允许发送HTML格式的)
#region
public
static
void
Sends(
string
email)
{
string
formto =
"发件箱地址"
;
string
to = email;
//接收邮箱
string
content =
""
;
string
body =
""
;
string
name =
"发件箱"
;
string
upass =
"密码"
;
string
smtp =
"smtp地址"
;
SmtpClient _smtpClient =
new
SmtpClient();
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
//指定电子邮件发送方式
_smtpClient.Host = smtp;
//指定SMTP服务器
_smtpClient.Credentials =
new
System.Net.NetworkCredential(name, upass);
//用户名和密码
MailMessage _mailMessage =
new
MailMessage();
//发件人,发件人名
_mailMessage.From =
new
MailAddress(formto,
"别名"
);
//收件人
_mailMessage.To.Add(to);
_mailMessage.SubjectEncoding = System.Text.Encoding.GetEncoding(
"gb2312"
);
_mailMessage.Subject = content;
//主题
_mailMessage.Body = body;
//内容
_mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding(
"gb2312"
);
//正文编码
_mailMessage.IsBodyHtml =
true
;
//设置为HTML格式
_mailMessage.Priority = MailPriority.High;
//优先级
try
{
_smtpClient.Send(_mailMessage);
}
catch
(Exception)
{
}
}
#endregion
//这是发送邮件的
//Body里放A标签(前提是IsBodyHtml 设为true,才会允许发送HTML格式的)
#region
public
static
void
Sends(
string
email)
{
string
formto =
"发件箱地址"
;
string
to = email;
//接收邮箱
string
content =
""
;
string
body =
""
;
string
name =
"发件箱"
;
string
upass =
"密码"
;
string
smtp =
"smtp地址"
;
SmtpClient _smtpClient =
new
SmtpClient();
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
//指定电子邮件发送方式
_smtpClient.Host = smtp;
//指定SMTP服务器
_smtpClient.Credentials =
new
System.Net.NetworkCredential(name, upass);
//用户名和密码
MailMessage _mailMessage =
new
MailMessage();
//发件人,发件人名
_mailMessage.From =
new
MailAddress(formto,
"别名"
);
//收件人
_mailMessage.To.Add(to);
_mailMessage.SubjectEncoding = System.Text.Encoding.GetEncoding(
"gb2312"
);
_mailMessage.Subject = content;
//主题
_mailMessage.Body = body;
//内容
_mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding(
"gb2312"
);
//正文编码
_mailMessage.IsBodyHtml =
true
;
//设置为HTML格式
_mailMessage.Priority = MailPriority.High;
//优先级
try
{
_smtpClient.Send(_mailMessage);
}
catch
(Exception)
{
}
}
#endregion