步骤一
[WebMethod]
public string SetEmail(string mail, string veCode,string UserName)
{
string msg = "Error";
if (UserName == "")
{
UserName = "";
}
string verCodes = veCode;
StringBuilder builder = new StringBuilder();
if (!new Regex(@"^[-_A-Za-z0-9]+@([_A-Za-z0-9\u4e00-\u9fa5]+\.)+[A-Za-z0-9]{2,4}$").IsMatch(mail))
{
return msg;
}
builder.AppendFormat(@"<p style='margin-left:15px'>亲爱的用户:</p>");
builder.AppendFormat(@"<p style='margin-left:43px'>{0} 您好!</p>", UserName);
builder.AppendFormat(@"<p style='margin-left:43px'>您收到此邮件是因为您在信阳游戏中心申请了邮箱绑定功能!如果不是您本人操作,请不必理会此邮件。</p>");
builder.AppendFormat(@"<p style='margin-left:15px'>");
builder.AppendFormat(@" 您正在将账户 {0} 绑定至密保邮箱 {1} ,此操作的验证码是 [<b style='color:red;'>{2}</b>] ,请将该验证码回填到验证页面,完成邮箱绑定。", UserName, mail, veCode);
builder.AppendFormat(@"</p>");
builder.AppendFormat(@"<p style='margin-left:15px'>");
builder.AppendFormat(@" 欢迎您使用信阳游戏中心,保护您的账户安全。");
builder.AppendFormat(@"</p>");
builder.AppendFormat(@"<p style='margin-left:15px'>");
builder.AppendFormat(@" 如果您有任何问题或建议,请拨打服务热线:<b style='color:red;'>2758321341</b>");
builder.AppendFormat(@" <a href='http://wpa.b.qq.com/cgi/wpa.php?ln=1&key=XzkzODAxMDA3Nl83OTI3MV80MDAwMDIzODE2XzJf' target='_blank'>4006117785</a>");
builder.AppendFormat(@"</p>");
builder.AppendFormat(@"<p style='margin-left:15px'>");
builder.AppendFormat(@" 爱上信阳:http://www.lovexyyx.com");
builder.AppendFormat(@"</p>");
builder.AppendFormat(@"<p style='margin-left:15px'>");
builder.AppendFormat(@" 注:这是一封自动生成的邮件,请勿直接回复本邮件。");
builder.AppendFormat(@"</p>");
MailUrls mailUrl = null;
try
{
NetEmailHelper mailPlugs = new NetEmailHelper();
mailPlugs.ToAddress = mail;
mailPlugs.Body = builder.ToString();
mailPlugs.Send();
mailUrl = mailPlugs.GetMailLoginUrl(mail);
msg = mailUrl == null ? "http://mail.qq.com" : mailUrl.MailLink;
msg = "OK";
// msg = "Ok|" + msg;
}
catch (ThreadAbortException exThread)
{
Logger.Log(exThread, "SendEmailThreadError");
}
catch (Exception ex)
{
}
return msg;
}
//步骤二
在项目根目录 新建一个 config 文件 里面添加一个stmpcon.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<root>
<StmpCon>
<ServerAddress>smtp.163.com</ServerAddress>
<FromAddress>guizhouhehai@163.com</FromAddress>
<FromPassWord>hehai1=1or1!=2</FromPassWord>
</StmpCon>
<StmpContentCon>
<Title>【信阳游戏管理中心验证邮件】绑定密保邮箱验证码 </Title>
</StmpContentCon>
</root>