自动发送Email

   

步骤一

 [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>

 

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值