当前位置: 首页>>代码示例>>C#>>正文


C# Database.InsertEmail方法代码示例

本文整理汇总了C#中db.Database.InsertEmail方法的典型用法代码示例。如果您正苦于以下问题:C# Database.InsertEmail方法的具体用法?C# Database.InsertEmail怎么用?C# Database.InsertEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Database的用法示例。


在下文中一共展示了Database.InsertEmail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            MD5 md5Hash = MD5.Create();

            string url = Program.Settings.GetValue("webUrl");

            string accessKey = "name:" + query["guid"] + "pass:" + query["password"];
            string hash = GetMd5Hash(md5Hash, accessKey);

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                db.InsertEmail(query["guid"], query["password"], hash);

                MySqlCommand cmd = db.CreateQuery();
                cmd.CommandText = "SELECT id, uuid, name, email FROM accounts WHERE [email protected]";
                cmd.Parameters.AddWithValue("@uuid", query["guid"]);
                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (!rdr.HasRows) return;
                    rdr.Read();

                    string to = rdr.GetString("email").ToLower();
                    string from = "[email protected]";
                    var message = new MailMessage(from, to);
                    message.Subject = "Email Verification for : " + rdr.GetString("uuid");
                    string htmlBody =
                        @"
            <html>
            <body style='font-family: 'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif;font-size: 13px;line-height: 20px;color: #333;margin:0;padding:0;'>
            <table cellspacing='0' cellpadding='0' border='0' width='100%'>
            <tr style='background: #3f3f3f'>
            <td class='navbar navbar-inverse' align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:auto;margin:0;padding:0;'>
                    <tr class='navbar navbar-inverse'>
                        <td><a style='margin:0px -3px;text-decoration:none;display: block;padding: 20px;font-size: 20px;font-weight: 200;color: rgb(241,241,241);text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.55);' href='http://forum.kithio.com'>Forums</a></li></ul></td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;margin-top:15px;'>
                    <tr>
                        <th colspan='2'><h1 style='margin: 10px 0px;font-family: inherit;font-weight: bold;line-height: 40px;font-size: 36px;color: inherit;text-rendering: optimizelegibility;margin-bottom: 35px;'>Email Verification</h1></th>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Account Name : </p></td><td style='width:58%;'><b>" +
                        rdr.GetString("uuid") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Character Name : </p></td><td style='width:58%;'><b>" +
                        rdr.GetString("name") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Email Address : </p></td><td style='width:58%;'><b style='color:#0063CA;text-decoration:none;'>" +
                        rdr.GetString("email") + @"</b></td>
                    </tr>
                    <tr>
                        <td colspan='2' align='center'>
                            <hr style='margin: 10px 0px;margin-top:35px;border-right: 0px none;border-left: 0px none;-moz-border-top-colors: none;-moz-border-right-colors: none;-moz-border-bottom-colors: none;-moz-border-left-colors: none;border-image: none;border-width: 1px 0px;border-style: solid none;border-color: #EEE -moz-use-text-color #FFF;'>
                            <p style='line-height: 20px;color: #333;font-size: 13px;'>
                                <a style='color: #0063CA;text-decoration: none;' href='http://" + url + @"/verify.php?email=" +
                        rdr.GetString("email").Replace("@", "%40") + @"&key=" + hash + @"'>
                                    <b><h3 style='font-size: 24px;line-height: 40px;margin-top: 30px;margin-bottom:20px;'>Click Here to Verify your Email Address</h3></b>
                                </a>
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;'>
                    <tr>
                        <td align='center' style='font-size:12pt;'>
                            <hr style='border-right: 0px none;border-left: 0px none;-moz-border-top-colors: none;-moz-border-right-colors: none;-moz-border-bottom-colors: none;-moz-border-left-colors: none;border-image: none;border-width: 1px 0px;border-style: solid none;border-color: #EEE -moz-use-text-color #FFF;'>
                            <p style='height:80px;margin-bottom:35px;'><b>Copyright &copy; 2014 | <a style='color: #0063CA;text-decoration:none;' href='http://forum.kithio.com'>Kithio</a></b></p>
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            </table>
            </body>
            </html>
            ";
                    message.Body = htmlBody;
                    message.IsBodyHtml = true;
                    var client = new SmtpClient();
                    // Credentials are necessary if the server requires the client
                    // to authenticate before it will send e-mail on the client's behalf.
                    client.Port = 587;
                    client.Host = "smtp.mandrillapp.com";
                    client.Credentials = new NetworkCredential("[email protected]", "xI7YXXrmtLC5BdwIEzsG0w");

//.........这里部分代码省略.........
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:101,代码来源:sendVerifyEmail.cs


注:本文中的db.Database.InsertEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。