Beispiel #1
0
        public int SendMailForRenewPassword(string strEmail)
        {
            try
            {
                UsersBAL objUser = new UsersBAL();
                UsersModel objUsersModel = objUser.FindUser(strEmail);

                if (objUsersModel == null)
                {
                    return 1;
                }

                //Update encode string in database
                objUser.UpdateUserStatus(objUsersModel.ID, objUsersModel.Status, Common.GetSHA1HashData(objUsersModel.EmailAddress));

                //Send email to user, from XSTL
                emailModel objEmailmodel = new emailModel();
                emailBAL objEmailBAL = new emailBAL();
                List<emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Reset-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {

                        DataRow DR = DT.Rows[0];
                        string FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);
                        XmlDocument xd = new XmlDocument();
                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(Common.GetSHA1HashData(objUsersModel.EmailAddress)) + "</encodestring></tbdoc>");
                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName = Convert.ToString(DR["from_name"]);
                        string subject = Convert.ToString(DR["subject"]);
                        string cc = Convert.ToString(DR["cc"]);
                        string bcc = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, objUsersModel.EmailAddress, cc, bcc, subject, body, true);
                        return 0;
                    }
                }

                return 2;
            }
            catch
            {
                return 2;
            }
        }
Beispiel #2
0
        /// <summary>
        /// RegisterNewUser
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int RegisterNewUser(string strEmailAddress, string password, string encodestring)
        {
            UsersBAL objUser = new UsersBAL();
            try
            {
                UsersModel objUsersModel = new UsersModel();
                objUsersModel.EmailAddress = strEmailAddress;
                objUsersModel.Password = password;
                objUsersModel.ID = 0;
                objUsersModel.Status = "pending";
                objUsersModel.encodestring = encodestring;
                int intNewUserRegistered = objUser.RegisterNewUSer(objUsersModel);
                //Send E-mail
                //SendEmail(Common.MailType.ConfirmRegistration, strEmailAddress);

                emailModel objEmailmodel = new emailModel();
                emailBAL objEmailBAL = new emailBAL();
                List<emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Register-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {

                        DataRow DR = DT.Rows[0];
                        string FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);

                        //string buffer = Common.ReadFileFromDisk(FileName, ref logger);

                        XmlDocument xd = new XmlDocument();

                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(encodestring) + "</encodestring></tbdoc>");

                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName = Convert.ToString(DR["from_name"]);
                        string subject = Convert.ToString(DR["subject"]);
                        string cc = Convert.ToString(DR["cc"]);
                        string bcc = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, strEmailAddress, cc, bcc, subject, body, true);
                    }
                }
                return intNewUserRegistered;
            }
            catch
            {
                return 2;
            }
            finally
            {
                objUser = null;
            }
        }