Exemplo n.º 1
0
        /// <summary>
        /// 创建邮件内容
        /// </summary>
        /// <param name="EmailTo"></param>
        /// <returns></returns>
        public EmailInfo CreateMailHtml(Playngo_ClientZone_GameSheet DataItem, UserInfo UserItem)
        {
            //构造邮件信息
            EmailInfo emailItem = new EmailInfo();

            emailItem.Settings = Settings;
            emailItem.PushSettings();


            //事件作者
            UserInfo EventUser = UserController.GetUserById(DataItem.PortalId, DataItem.CreateUser);

            string Template_Subject = NetHelper.ReplaceNoCase(MailSetting.MailSubject, "[TITLE]", DataItem.Title);

            Template_Subject = NetHelper.ReplaceNoCase(Template_Subject, "[MAILSETTING_TIME]", MailSetting.MailTime.ToString());



            Template_Subject = NetHelper.ReplaceNoCase(Template_Subject, "[AUTHOR_MAIL]", EventUser.Email);
            Template_Subject = NetHelper.ReplaceNoCase(Template_Subject, "[AUTHOR_USERNAME]", EventUser.Username);
            Template_Subject = NetHelper.ReplaceNoCase(Template_Subject, "[AUTHOR_DISPLAYNAME]", EventUser.DisplayName);



            emailItem.Subject = Template_Subject;

            #region "构造邮件信息"

            String Template_Content = NetHelper.ReplaceNoCase(MailSetting.MailBody, "[TITLE]", DataItem.Title);
            //Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[CONTENTTEXT]", HttpUtility.HtmlDecode(DataItem.ContentText));
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[CREATETIME]", DataItem.CreateTime.ToString());
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[CREATEDATE]", DataItem.CreateTime.ToShortDateString());
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[MAILSETTING_TIME]", MailSetting.MailTime.ToString());
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[DATETIME_NOW]", xUserTime.LocalTime().ToString());


            //注册的信息丢进来
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[AUTHOR_MAIL]", EventUser.Email);
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[AUTHOR_USERNAME]", EventUser.Username);
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[AUTHOR_DISPLAYNAME]", EventUser.DisplayName);

            //订阅用户的信息丢进来
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[USER_MAIL]", UserItem.Email);
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[USER_USERNAME]", UserItem.Username);
            Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[USER_DISPLAYNAME]", UserItem.DisplayName);


            //图片替换
            if (Common.Contains(Template_Content, "[PICTURE]"))
            {
                Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[PICTURE]", FormatThumbnailUrl(DataItem));
            }

            //文章链接
            if (Common.Contains(Template_Content, "[LINK]"))
            {
                Template_Content = NetHelper.ReplaceNoCase(Template_Content, "[LINK]", FormatItemUrl(DataItem));
            }

            emailItem.Content = Template_Content;
            #endregion



            emailItem.MailTo = MailSetting.MailTo;
            if (MailSetting.MailTo.ToUpper() == "[AUTHOR_MAIL]")//用户邮件需要发送给作者
            {
                emailItem.MailTo = EventUser.Email;
            }
            else if (MailSetting.MailTo.ToUpper() == "[USER_MAIL]")//用户邮件需要发送给用户
            {
                emailItem.MailTo = UserItem.Email;
            }
            emailItem.MailCC = MailSetting.MailCC;

            return(emailItem);
        }