Esempio n. 1
0
 public void TestAddFilterSetting()
 {
     var test = new Header();
     test.AddFilterSetting("foo", new List<string> { "a", "b" }, "bar");
     var result = test.AsJson();
     Assert.AreEqual("{\"filters\" : {\"foo\" : {\"settings\" : {\"a\" : {\"b\" : \"bar\"}}}}}", result);
 }
Esempio n. 2
0
        public void EnableBcc(string email)
        {
            var filter = Filters["Bcc"];

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "email"
            }, email);
        }
Esempio n. 3
0
        public void EnableUnsubscribe(string replace)
        {
            var filter = Filters["Unsubscribe"];

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "replace"
            }, replace);
        }
Esempio n. 4
0
        public void EnableFooter(string text = null, string html = null)
        {
            var filter = Filters["Footer"];

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "text/plain"
            }, text);
            Header.AddFilterSetting(filter, new List <string> {
                "text/html"
            }, html);
        }
Esempio n. 5
0
        public void EnableSpamCheck(int score = 5, string url = null)
        {
            var filter = Filters["SpamCheck"];

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "maxscore"
            }, score.ToString(CultureInfo.InvariantCulture));
            Header.AddFilterSetting(filter, new List <string> {
                "url"
            }, url);
        }
Esempio n. 6
0
        public void EnableClickTracking(bool includePlainText = false)
        {
            var filter = Filters["ClickTracking"];

            Header.EnableFilter(filter);
            if (includePlainText)
            {
                Header.AddFilterSetting(filter, new List <string> {
                    "enable_text"
                }, "1");
            }
        }
Esempio n. 7
0
        public void EnableTemplate(string html)
        {
            var filter = Filters["Template"];

            if (!Regex.IsMatch(html, ReHtml))
            {
                throw new Exception("Missing substitution replacementTag in html");
            }

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "text/html"
            }, html);
        }
Esempio n. 8
0
        public void EnableGoogleAnalytics(string source, string medium, string term, string content = null, string campaign = null)
        {
            var filter = Filters["GoogleAnalytics"];

            Header.Enable(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "utm_source"
            }, source);
            Header.AddFilterSetting(filter, new List <string> {
                "utm_medium"
            }, medium);
            Header.AddFilterSetting(filter, new List <string> {
                "utm_term"
            }, term);
            Header.AddFilterSetting(filter, new List <string> {
                "utm_content"
            }, content);
            Header.AddFilterSetting(filter, new List <string> {
                "utm_campaign"
            }, campaign);
        }
Esempio n. 9
0
        public void EnableUnsubscribe(string text, string html)
        {
            var filter = Filters["Unsubscribe"];

            if (!Regex.IsMatch(text, ReText))
            {
                throw new Exception("Missing substitution replacementTag in text");
            }

            if (!Regex.IsMatch(html, ReHtml))
            {
                throw new Exception("Missing substitution replacementTag in html");
            }

            Header.EnableFilter(filter);
            Header.AddFilterSetting(filter, new List <string> {
                "text/plain"
            }, text);
            Header.AddFilterSetting(filter, new List <string> {
                "text/html"
            }, html);
        }