Beispiel #1
0
        public string GetContentWithCode(ContentType type, string code)
        {
            string filename           = string.Empty;
            string mainMessageContent = string.Empty;

            switch (type)
            {
            case ContentType.ResetPassword:
                filename           = resetPasswordFileName;
                mainMessageContent = "In order to reset your password use code below.";
                break;

            case ContentType.ActivateAccount:
                filename           = confirmAccountFileName;
                mainMessageContent = "In order to confirm your account use code below.";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            string htmlContent = StaticFileReader.GetFileText($"EmailSender.templates.{filename}");

            htmlContent = htmlContent.Replace(userEmail, _email);
            htmlContent = htmlContent.Replace(generatedCode, code);
            htmlContent = htmlContent.Replace(unwantedMessage, "If this message is unwanted, please let us know [email protected]");
            htmlContent = htmlContent.Replace(mainMessage, mainMessageContent);

            return(htmlContent);
        }
        public EmailConfigurationModel GetCredentials()
        {
            string fileContent = StaticFileReader.GetFileText($"EmailSender.credentials.{credentialsFileName}");
            var    model       = JsonConvert.DeserializeObject <EmailConfigurationModel>(fileContent);

            return(model);
        }