예제 #1
0
        private void SetTemplateInfo(MailTemplateInfo info)
        {
            EmailTemplateHtml = Encoding.UTF8.GetString((new WebClient()).DownloadData(info.EmailTemplateUrl));//取得html碼

            if (info.TemplateItems != null)
            {
                Type           type          = info.TemplateItems.GetType();
                PropertyInfo[] propertyInfos = type.GetProperties();

                foreach (var item in propertyInfos)
                {
                    if (item.PropertyType == typeof(DateTime))
                    {
                        DateTime dateTimeVal = Convert.ToDateTime(item.GetValue(info.TemplateItems, null));
                        EmailTemplateHtml = EmailTemplateHtml.Replace($"[{item.Name}]", dateTimeVal.ToString());
                    }
                    else
                    {
                        var val = item.GetValue(info.TemplateItems, null).ToString();
                        EmailTemplateHtml = EmailTemplateHtml.Replace($"[{item.Name}]", val);
                    }
                }
            }
        }
예제 #2
0
 public MailInfo(MailTemplateInfo info)
 {
     SetTemplateInfo(info);
 }