Пример #1
0
        /// <summary>
        /// Sends the OTP code for password reset
        /// </summary>
        /// <param name="emailAddress"></param>
        /// <param name="OTPCode"></param>
        public static void SendOTPForPwdReset(string emailAddress, string OTPCode)
        {
            List <string> recipients = new List <string>();

            recipients.Add(emailAddress);

            string     codeBase          = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri               = new UriBuilder(codeBase);
            string     Uripath           = Uri.UnescapeDataString(uri.Path);
            string     ENOTPCode         = HttpUtility.UrlEncode(OTPCode);
            string     path              = Path.GetDirectoryName(Uripath);
            string     EmailTemplatePath = @"\Common\EmailTemplate\HTML\GetOTPEmail.html";
            string     ActivateUrl       = ConfigurationManager.AppSettings["WEBAPP_URL"].ToString() + "#/auth/reset-password?code=" + ENOTPCode + "&email=" + emailAddress;

            string htmlTemplateData = File.ReadAllText(path.Remove(path.Length - 3) + EmailTemplatePath);

            htmlTemplateData = htmlTemplateData.Replace("[OTPCode]", OTPCode)
                               .Replace("[emailAddress]", emailAddress)
                               .Replace("[ENOTPCode]", ENOTPCode)
                               .Replace("[URL]", ActivateUrl)
                               .Replace("[OTPSpan]", ConfigurationManager.AppSettings["OTP_TIMESPAN"]);

            string subject = "LGSE OTP";

            //string body = "Please use the OTP code " + OTPCode + " to reset your password <br>";
            //body += "csp://forgetpassword?code=" + OTPCode + "&email=" + emailAddress;
            SendGridUtilities.SendEmail(recipients, subject, htmlTemplateData);
        }
Пример #2
0
        /// <summary>
        /// Sends the OTP code to User
        /// </summary>
        /// <param name="emailAddress"></param>
        /// <param name="OTPCode"></param>
        public static void SendOTPtoUser(string emailAddress, string OTPCode)
        {
            List <string> recipients = new List <string>();

            recipients.Add(emailAddress);
            string     ENOTPCode = HttpUtility.UrlEncode(OTPCode);
            string     codeBase  = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri       = new UriBuilder(codeBase);
            string     Uripath   = Uri.UnescapeDataString(uri.Path);
            string     path      = Path.GetDirectoryName(Uripath);

            string ActivateUrl       = ConfigurationManager.AppSettings["WEBAPP_URL"].ToString() + "#/auth/activate?code=" + ENOTPCode + "&workemail=" + emailAddress;
            string EmailTemplatePath = @"\Common\EmailTemplate\HTML\UserActivationEmail.html";

            string htmlTemplateData = File.ReadAllText(path.Remove(path.Length - 3) + EmailTemplatePath);

            htmlTemplateData = htmlTemplateData.Replace("[OTPCode]", OTPCode)
                               .Replace("[emailAddress]", emailAddress)
                               .Replace("[ENOTPCode]", ENOTPCode)
                               .Replace("[URL]", ActivateUrl)
                               .Replace("[OTPSpan]", ConfigurationManager.AppSettings["OTP_TIMESPAN"]);

            string subject = "LGSE Activation Code";

            SendGridUtilities.SendEmail(recipients, subject, htmlTemplateData);
        }
Пример #3
0
        /// <summary>
        /// Send the new Password
        /// </summary>
        /// <returns></returns>
        /// <param name="emailAddress"></param>
        /// <param name="Password"></param>
        internal static void SendPasswordtoUser(string emailAddress, string Password)
        {
            List <string> recipients = new List <string>();

            recipients.Add(emailAddress);

            string     codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri      = new UriBuilder(codeBase);
            string     Uripath  = Uri.UnescapeDataString(uri.Path);
            //string ENOTPCode = HttpUtility.UrlEncode(OTPCode);
            string path = Path.GetDirectoryName(Uripath);
            string EmailTemplatePath = @"\Common\EmailTemplate\HTML\GetPasswordEmail.html";
            //string ActivateUrl = ConfigurationManager.AppSettings["WEBAPP_URL"].ToString() + "#/auth/reset-password?code=" + ENOTPCode + "&email=" + emailAddress;

            string htmlTemplateData = File.ReadAllText(path.Remove(path.Length - 3) + EmailTemplatePath);

            htmlTemplateData = htmlTemplateData.Replace("[Password]", Password);

            string subject = "New Password send by Admin";

            //string body = "Please use the OTP code " + OTPCode + " to reset your password <br>";
            //body += "csp://forgetpassword?code=" + OTPCode + "&email=" + emailAddress;
            SendGridUtilities.SendEmail(recipients, subject, htmlTemplateData);
        }