예제 #1
0
        public string SendMailUseGmail()
        {
            int     recid        = GameRequest.GetInt("taskid", 0);
            string  systemname   = GameRequest.GetQueryString("platform");
            string  sql          = string.Format(@"  select npct.RecID as taskid,gi.GameDisplayName,u.Compellation,npct.CollectDatetime,dpf.PlatformDisplayName from 
  [{1}] npct
  inner join sdk_DefaultPlatform dpf on npct.RecID={0} and npct.PlatFormID=dpf.Id
  inner join sdk_GameInfo gi on npct.GameID=gi.GameID
  inner join AspNetUsers u on npct.CreateUser=u.Email", recid, systemname == "Android" ? "sdk_NewPackageCreateTask" : "sdk_NewPackageCreateTask_IOS");
            DataSet ds           = aideNativeWebFacade.GetDataSetBySql(sql);
            string  createuser   = "";
            string  gamename     = "";
            string  platformname = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                createuser   = ds.Tables[0].Rows[0]["Compellation"].ToString();
                gamename     = ds.Tables[0].Rows[0]["GameDisplayName"].ToString();
                platformname = ds.Tables[0].Rows[0]["PlatformDisplayName"].ToString();
            }

            string toMail = GameRequest.GetQueryString("platform") == "Android" ? System.Configuration.ConfigurationManager.AppSettings["SDKPackageLoseEmail_Android"] : System.Configuration.ConfigurationManager.AppSettings["SDKPackageLoseEmail_IOS"];


            string subject = string.Format("打包任务失败({0},{1},{2},{3},{4})", recid, gamename, systemname, platformname, createuser);//邮件标题
            string context = GetErrorLog(ds);

            return(SendEamil.SendMailUseGmail(toMail, subject, context));
        }
예제 #2
0
 protected void Forgot(object sender, EventArgs e)
 {
     if (IsValid)
     {
         // 验证用户密码
         var             manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
         ApplicationUser user    = manager.FindByName(Email.Text);
         if (user == null || !manager.IsEmailConfirmed(user.Id))
         {
             FailureText.Text     = "用户不存在或未确认。";
             ErrorMessage.Visible = true;
             return;
         }
         // 有关如何启用帐户确认和密码重置的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=320771
         // 发送包含此代码和重定向到“重置密码”页的电子邮件
         string code = manager.GeneratePasswordResetToken(user.Id);
         code = Server.UrlEncode(code);
         string callbackUrl = IdentityHelper.GetResetPasswordRedirectUrl(code);
         string context     = "您刚申请了打包平台密码重置,请通过单击 <a href=\"{0}\">此处</a> 来重置你的密码。如非本人申请请勿点击链接。";
         //manager.SendEmail(user.Id, "重置密码", "请通过单击 <a href=\"" + callbackUrl + "\">此处</a> 来重置你的密码。");
         string message = SendEamil.SendMailUseGmail(Email.Text, code, callbackUrl, context);//SendEamil.SendEmail(Email.Text, code, callbackUrl, context);
         this.FailureText.Text = message;
         ErrorMessage.Visible  = true;
     }
 }
예제 #3
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user    = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text
            };
            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                IdentityHelper.SignIn(manager, user, isPersistent: false);

                // 有关如何启用帐户确认和密码重置的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=320771
                string code = manager.GenerateEmailConfirmationToken(user.Id);
                code = Server.UrlEncode(code);
                string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id);
                //manager.SendEmail(user.Id, "渠道打包平台注册邮件地址确认", "您刚申请了渠道打包平台账号,请通过单击 <a href=\"" + callbackUrl + "\">此处 </a> 来确认你的帐户。如非本人申请请勿点击链接。");
                string context  = "您刚申请了打包平台账号,请通过单击 <a href=\"{0}\">此处 </a> 来确认你的帐户。如非本人申请请勿点击链接。";
                string SendMail = SendEamil.SendMailUseGmail(user.Email, code, callbackUrl, context);
                if (SendMail == "验证邮件发送失败")
                {
                    FailureText.Text     = SendMail;
                    ErrorMessage.Visible = true;
                }
                else
                {
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                }
            }
            else
            {
                FailureText.Text     = result.Errors.FirstOrDefault();
                ErrorMessage.Visible = true;
            }
        }
예제 #4
0
    /// <summary>
    /// 发送邮件并保存到服务器
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        //获得所需参数
        string str2 = tb_Email.Text.Trim();

        //把;替换为;
        str2 = str2.Replace(";", ";");
        //如果不是;结尾就加上

        if (!str2.EndsWith(";"))
        {
            str2 += ";";
        }
        //去除地址中的用户名

        for (int i = 0; i >= 0; i++)
        {
            int startstr = str2.IndexOf("[");
            int endstr   = str2.IndexOf("];") + 1;
            if (startstr >= 0)
            {
                str2 = str2.Remove(startstr, (endstr - startstr));
            }
            else
            {
                break;
            }
        }
        string        str3     = str2;
        List <string> strlist  = new List <string>();
        List <string> strlist2 = new List <string>();
        //根据样式获取正确的邮箱地址
        Regex           rx      = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        MatchCollection matches = rx.Matches(str2);

        foreach (Match var in matches)
        {
            strlist2.Add(var.Value);
        }
        for (int i = 0; i >= 0; i++)
        {
            int endstr = str3.IndexOf(";");
            if (endstr >= 0)
            {
                //截取邮箱地址
                strlist.Add(str3.Substring(0, endstr));
                str3 = str3.Remove(0, (str3.Substring(0, endstr)).Length + 1);
                if (strlist.Count <= strlist2.Count)
                {
                    //如果地址不同就代表格式不正确
                    if (strlist[i] != strlist2[i])
                    {
                        Response.Write("<script type='text/javascript'>alert('" + strlist[i] + "的格式错误')</script>");
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            else
            {
                break;
            }
        }
        string         strTitle   = "隧道OA办公系统:" + tb_Title.Text.Trim();
        string         strContent = tb_content.Text.Trim();
        HttpPostedFile hpf        = file1.PostedFile;

        if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10)
        {
            Response.Write("<script>alert('附件大小不能大于10MB');</script>");

            return;
        }
        else
        {
            CreateMdAndFilePaht();
        }
        string[] arr = new string[1];
        if (hpf.ContentLength > 0)
        {
            if (!string.IsNullOrEmpty(hpf.FileName))
            {
                fileName = fileName + System.IO.Path.GetExtension(hpf.FileName);
            }
            else
            {
                fileName = fileName + hpf.ContentType;
            }
            filePaht      = upDbFilePaht + fileName;
            fileDirectory = fileDirectory + fileName;
            arr[0]        = fileDirectory;
            hpf.SaveAs(fileDirectory);
        }
        else
        {
            filePaht = string.Empty;
        }
        int relt1 = 0;

        for (int i = 0; i < strlist.Count; i++)
        {
            //发送邮件

            SendEamil se   = new SendEamil();
            int       relt = -1;

            relt = se.SendEmail(se.NcUserEmail, strlist[i], strTitle, strContent, arr);

            //写入数据库

            Tunnel.BLL.Tunnel_report   rbll  = new Tunnel.BLL.Tunnel_report();
            Tunnel.Model.Tunnel_report model = new Tunnel.Model.Tunnel_report();
            model.r_title   = strTitle;
            model.r_Content = strContent;
            model.r_file    = filePaht;
            model.r_time    = DateTime.Now;
            model.r_user    = ul.LoginID;
            model.r_toEmail = strlist[i];
            model.r_Ip      = Tunnel.Common.Common.GetIp();
            rbll.Add(model);
            relt1++;
        }
        if (relt1 == strlist.Count)
        {
            string str = "邮件";
            string url = "N_MailManage.aspx";
            if (relt1 > 0)
            {
                str += "发送成功!";
            }
            else
            {
                str += "发送失败!";
            }

            MessageBox(str, url);
        }
    }