コード例 #1
0
        private string ReplaceText(IEmailTemplate model, string body)
        {
            foreach (PropertyInfo propertyInfo in model.GetType().GetProperties())
            {
                string propertyName  = "@[" + propertyInfo.Name + "]";
                string propertyValue = propertyInfo.GetValue(model, null)?.ToString();

                body = body.Replace(propertyName, propertyValue);
            }

            return(body);
        }
コード例 #2
0
        public Email GetTemplate(IEmailTemplate email)
        {
            Guard.NotNull(email, nameof(email));

            var variables = email.GetVariablesToReplace();

            var template = this.ReadEmailTemplate(email.GetType());
            template.Subject = this.ReplaceVariables(template.Subject, variables);
            template.Body = this.ReplaceVariables(template.Body, variables);
            template.Sender = email.Sender;

            return template;
        }