Example #1
0
        public EmailReplacements(CMSDataContext callingContext, string text, MailAddress from, int?queueid = null, bool noPremailer = false, DynamicData pythondata = null)
        {
            currentOrgId = Util2.CurrentOrgId;
            connStr      = callingContext.ConnectionString;
            host         = callingContext.Host;
            db           = callingContext;
            pythonData   = pythondata;
            this.from    = from;
            if (queueid > 0)
            {
                OptOuts = db.OptOuts(queueid, from.Address).ToList();
            }

            if (text == null)
            {
                text = "(no content)";
            }

            // we do the InsertDrafts replacement code here so that it is only inserted once before the replacements
            // and so that there can be replacement codes in the draft itself and they will get replaced.
            text = DoInsertDrafts(text);
            text = ColorCodesReplacement(text);

            text = MapUrlEncodedReplacementCodes(text, new[] { "emailhref" });
            if (!noPremailer)
            {
                try
                {
                    text = text.Replace("{{", "<!--{{").Replace("}}", "}}-->");
                    var result = PreMailer.Net.PreMailer.MoveCssInline(text);
                    text = result.Html;
                    text = text.Replace("<!--{{", "{{").Replace("}}-->", "}}");
                    // prevent gmail from not rendering when an empty title is autoclosed.
                    text = text.Replace("<title />", "<title></title>");
                }
                catch
                {
                    // ignore Premailer exceptions
                }
            }

            stringlist = Regex.Split(text, Pattern1, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
        }
Example #2
0
        public EmailReplacements(CMSDataContext callingContext, string text, MailAddress from, int?queueid = null, bool noPremailer = false, DynamicData pythondata = null)
        {
            currentOrgId = callingContext.CurrentOrgId;
            connStr      = callingContext.ConnectionString;
            host         = callingContext.Host;
            db           = callingContext;
            pythonData   = pythondata;
            this.from    = from;
            if (queueid > 0)
            {
                OptOuts = db.OptOuts(queueid, from.Address).ToList();
            }

            if (text == null)
            {
                text = "(no content)";
            }


            var pattern =
                $@"(<style.*?</style>|{MatchCodeRe}|{MatchRegisterLinkRe}|{MatchRegisterTagRe}|{MatchRsvpLinkRe}|{MatchRegisterLinkHrefRe}|{MatchDropFromOrgTagRe}|
                    {MatchSendLinkRe}|{MatchSupportLinkRe}|{MatchMasterLinkRe}|{MatchVolReqLinkRe}|{MatchVolReqLinkRe}|{MatchVolSubLinkRe}|{MatchVoteLinkRe})";

            // we do the InsertDrafts replacement code here so that it is only inserted once before the replacements
            // and so that there can be replacement codes in the draft itself and they will get replaced.
            text = DoInsertDrafts(text);

            text = MapUrlEncodedReplacementCodes(text, new[] { "emailhref" });
            if (!noPremailer)
            {
                try
                {
                    var result = PreMailer.Net.PreMailer.MoveCssInline(text);
                    text = result.Html;
                }
                catch
                {
                    // ignore Premailer exceptions
                }
            }

            stringlist = Regex.Split(text, pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
        }
Example #3
0
        public EmailReplacements(CMSDataContext callingContext, string text, MailAddress from, int? queueid = null)
        {
            currentOrgId = callingContext.CurrentOrgId;
            connStr = callingContext.ConnectionString;
            host = callingContext.Host;
            db = callingContext;
            this.from = from;
            if(queueid > 0)
                OptOuts = db.OptOuts(queueid, from.Address).ToList();

            if (text == null)
                text = "(no content)";

            var pattern =
                $@"(<style.*?</style>|{{[^}}]*?}}|{RegisterLinkRe}|{RegisterTagRe}|{RsvpLinkRe}|{RegisterHrefRe}|
                    {SendLinkRe}|{SupportLinkRe}|{MasterLinkRe}|{VolReqLinkRe}|{VolReqLinkRe}|{VolSubLinkRe}|{VoteLinkRe})";

            // we do the InsertDrafts replacement code here so that it is only inserted once before the replacements
            // and so that there can be replacement codes in the draft itself and they will get replaced.
            text = DoInsertDrafts(text);

            text = MapUrlEncodedReplacementCodes(text, new[] { "emailhref" });
            try
            {
                var result = PreMailer.Net.PreMailer.MoveCssInline(text);
                text = result.Html;
            }
            catch
            {
                // ignore Premailer exceptions
            }

            stringlist = Regex.Split(text, pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
        }