Ejemplo n.º 1
0
        Mail Create(string subject, string contentType, byte[] body)
        {
            Mail mail = new Mail(null);

            mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            //ヘッダ作成
            mail.AddHeader("subject", subject);
            mail.AddHeader("Content-Type", contentType);
            //本文作成
            mail.Init(body);
            return(mail);
        }
Ejemplo n.º 2
0
        public TsMail(string from, string to, string bodyStr)
        {
            Mail = new Mail();
            Mail.AppendLine(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            var body = Encoding.ASCII.GetBytes(bodyStr);

            Mail.AppendLine(body);
            Mail.AddHeader("from", from);
            Mail.AddHeader("to", to);

            const string host = "TEST";
            var          addr = new Ip("10.0.0.1");

            MlEnvelope = new MlEnvelope(CreateMailAddress(from), CreateMailAddress(to), host, addr);
        }
Ejemplo n.º 3
0
        Mail Create(string subject, string contentType, byte[] body)
        {
            var mail = new Mail();

            mail.AppendLine(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            //ヘッダ作成
            mail.AddHeader("subject", subject);
            mail.AddHeader("Content-Type", contentType);
            mail.AddHeader("from", _mlAddr.Admin.ToString());
            mail.AddHeader("date", Util.LocalTime2Str(DateTime.Now));//日付

            //本文作成
            mail.AppendLine(body);
            return(mail);
        }
Ejemplo n.º 4
0
        public void AddHeaderによるヘッダの追加()
        {
            //setUp
            const string val = "value1";
            const string tag = "tag";

            var expected = val;

            //exerceise
            sut.AddHeader(tag, val);
            var actual = sut.GetHeader(tag);

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 5
0
        //元メールを添付して管理者へ送る
        public bool AttachToAmdin(Mail orgMail, string subject, MlEnvelope mlEnvelope)
        {
            //メール生成
            var mail = new Mail();

            mail.AppendLine(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            mail.AddHeader("subject", subject);
            mail.AppendLine(Encoding.ASCII.GetBytes(subject + "\r\n"));
            mail.AppendLine(Encoding.ASCII.GetBytes("\r\n"));
            mail.AppendLine(Encoding.ASCII.GetBytes("Original mail as follows:\r\n"));
            mail.AppendLine(Encoding.ASCII.GetBytes("\r\n"));
            //オリジナルメールの添付
            var body = Inet.GetLines(orgMail.GetBytes());

            foreach (var buf in body)
            {
                mail.AppendLine(Encoding.ASCII.GetBytes("  "));//行頭に空白を追加
                mail.AppendLine(buf);
            }

            //宛先設定 from<->To from = mailDaemon
            mail.ConvertHeader("from", _mlAddr.Admin.ToString());
            //配送
            return(SendAllAdmin(mlEnvelope.ChangeFrom(_mlAddr.Admin), mail));
        }
Ejemplo n.º 6
0
        public void Readによるn通目の読み込み(int n)
        {
            //setUp
            var max        = 10;
            var threadSpan = 0; //最小経過時間

            var mail     = new Mail();
            var expected = string.Format("{0}", n);

            mail.AddHeader("tag", expected);
            var mailInfo = CreateMailInfo();

            for (int i = 0; i < max; i++)
            {
                sut.Save(mail, mailInfo);
            }
            var list = sut.GetList(max, threadSpan);

            //exerceise
            sut.Read(list[n].MailInfo.FileName, ref mail);
            var actual = mail.GetHeader("tag");

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Demonstrates declaratively defining all email properties with parameter binding
 /// to message properties.
 /// </summary>
 public static void ProcessOrder_Declarative(
     [QueueTrigger(@"samples-orders")] Order order,
     [SendGrid(
          To = "{CustomerEmail}",
          Subject = "Thanks for your order (#{OrderId})!",
          Text = "{CustomerName}, we've received your order ({OrderId}) and have begun processing it!")]
     out Mail message)
 {
     // You can set additional message properties here
     message = new Mail();
     message.AddHeader("MyHeader", "MyValue");
 }
Ejemplo n.º 8
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";

            //Docs
            Docs = new List<string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));
            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) {
                var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines) {
                    if (l.IndexOf(tag) == 0) {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit) {
                    Docs.Add("");
                }
            }

            Kernel = new Kernel(null, null, null, null);
            Logger = Kernel.CreateLogger("LOG", true, null);
            domainList = new List<string>() { "example.com" };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel,"","");
            var mailBox = new MailBox(Kernel, oneOption);
            MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++) {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文

                Ml.Save(mail);
            }
        }
Ejemplo n.º 9
0
        public void Relpaceによるヘッダの置き換え()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });

            replace.Add(true, "ABC\tXYZ");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();

            mail.AddHeader("tag1", "ABC123");
            mail.AddHeader("tag2", "DEF123");
            mail.AddHeader("tag3", "GHI123");

            var expected = "tag1: XYZ123\r\n";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = Encoding.ASCII.GetString(mail.GetBytes()).Substring(0, 14);

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 10
0
        public void Relpaceによるヘッダの置き換え2()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });

            replace.Add(true, "ABC\tBBB");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();

            mail.AddHeader("tag1", "ABC123");
            mail.AddHeader("tag2", "DEF123");
            mail.AddHeader("tag3", "GHI123");

            var expected = "BBB123";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("tag1");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 11
0
        public void Relpaceによるヘッダの置き換え3()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });

            replace.Add(true, "EFGH\tWXYZ");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();

            mail.AddHeader("To", "\"ABCD\" <****@******>");
            mail.AddHeader("From", "\"EFGH\" <****@******>");
            mail.AddHeader("Subject", "test");

            var expected = "\"WXYZ\" <****@******>";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("From");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 12
0
        public TestMail(string from, string to, string bodyStr)
        {
            this.Mail = new Mail(null);
            Mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            var body = Encoding.ASCII.GetBytes(bodyStr);

            Mail.Init(body);
            Mail.AddHeader("from", from);
            Mail.AddHeader("to", to);

            var host = "TEST";
            var addr = new Ip("10.0.0.1");

            MlEnvelope = new MlEnvelope(CreateMailAddress(from), CreateMailAddress(to), host, addr);
        }
Ejemplo n.º 13
0
 //変換と追加
 public void Exec(Mail mail, Logger logger)
 {
     Debug.Assert(logger != null, "logger != null");
     //ヘッダ変換
     foreach (var a in _replace)
     {
         if (mail.RegexHeader(a.Key, a.Value))
         {
             logger.Set(LogKind.Normal, null, 16, string.Format("{0} -> {1}", a.Key, a.Value));
         }
     }
     //ヘッダの追加
     foreach (var a in _append)
     {
         mail.AddHeader(a.Key, a.Value);
         logger.Set(LogKind.Normal, null, 17, string.Format("{0}: {1}", a.Key, a.Value));
     }
 }
Ejemplo n.º 14
0
 //メールを添付する
 public Mail Attach(string subject, Mail orgMail)
 {
     var mail = new Mail(orgMail.Logger);
     mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
     //ヘッダ作成
     mail.AddHeader("subject", subject);
     //本文作成
     mail.Init(Encoding.ASCII.GetBytes(subject + "\r\n"));
     mail.Init(Encoding.ASCII.GetBytes("\r\n"));
     mail.Init(Encoding.ASCII.GetBytes("Original mail as follows:\r\n"));
     mail.Init(Encoding.ASCII.GetBytes("\r\n"));
     //オリジナルメールの添付
     List<byte[]> body = Inet.GetLines(orgMail.GetBytes());
     foreach (byte[] buf in body) {
         mail.Init(Encoding.ASCII.GetBytes("  "));//行頭に空白を追加
         mail.Init(buf);
     }
     return mail;
 }
Ejemplo n.º 15
0
        public void Relpaceによるヘッダの置き換え4()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });

            replace.Add(true, "User-Agent:.*\tUser-Agent:Henteko Mailer 09.87.12");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();

            mail.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8");

            var expected = "Henteko Mailer 09.87.12";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("User-Agent");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 16
0
        //メールを添付する
        public Mail Attach(string subject, Mail orgMail)
        {
            var mail = new Mail(orgMail.Logger);

            mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
            //ヘッダ作成
            mail.AddHeader("subject", subject);
            //本文作成
            mail.Init(Encoding.ASCII.GetBytes(subject + "\r\n"));
            mail.Init(Encoding.ASCII.GetBytes("\r\n"));
            mail.Init(Encoding.ASCII.GetBytes("Original mail as follows:\r\n"));
            mail.Init(Encoding.ASCII.GetBytes("\r\n"));
            //オリジナルメールの添付
            List <byte[]> body = Inet.GetLines(orgMail.GetBytes());

            foreach (byte[] buf in body)
            {
                mail.Init(Encoding.ASCII.GetBytes("  "));//行頭に空白を追加
                mail.Init(buf);
            }
            return(mail);
        }
Ejemplo n.º 17
0
 Mail Create(string subject, string contentType, byte[] body)
 {
     Mail mail = new Mail(null);
     mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
     //ヘッダ作成
     mail.AddHeader("subject", subject);
     mail.AddHeader("Content-Type", contentType);
     //本文作成
     mail.Init(body);
     return mail;
 }
Ejemplo n.º 18
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";


            //Docs
            Docs = new List <string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));

            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind)))
            {
                var  tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines)
                {
                    if (l.IndexOf(tag) == 0)
                    {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit)
                {
                    Docs.Add("");
                }
            }

            Kernel     = new Kernel(null, null, null, null);
            Logger     = Kernel.CreateLogger("LOG", true, null);
            domainList = new List <string>()
            {
                "example.com"
            };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel, "", "");
            var mailBox   = new MailBox(Kernel, oneOption);

            MailSave = new MailSave(Kernel, mailBox, Logger, mailQueue, "", domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++)
            {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));  //区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n")); //本文

                Ml.Save(mail);
            }
        }
Ejemplo n.º 19
0
        //Server及びMlから使用される
        //メールの保存(宛先はML以外であることが確定してから使用する)
        //テスト用のモックオブジェクト(TsMailSaveでSave()をオーバーライドできるようにvirtualにする
        virtual public bool Save(MailAddress from, MailAddress to, Mail orgMail, string host, Ip addr)
        {
            //Mailのヘッダ内容等を変更するので、この関数内だけの変更にとどめるため、テンポラリを作成する
            var mail = new Mail(); //orgMail.CreateClone();

            mail.Init2(orgMail.GetBytes());

            //ユニークなID文字列の生成
            var uidStr = string.Format("bjd.{0:D20}.{1:D3}", DateTime.Now.Ticks, _idCounter++);

            //日付文字列の生成
            //var date = Util.LocalTime2Str(DateTime.Now);
            //Receivedヘッダの追加
            mail.AddHeader("Received", _receivedHeader.Get(to, host, addr));

//            //Message-Idの追加
//            if (null == mail.GetHeader("Message-ID"))
//                mail.AddHeader("Message-ID", string.Format("<{0}@{1}>", uidStr, _domainList[0]));
//            //Fromの追加
//            if (null == mail.GetHeader("From"))
//                mail.AddHeader("From", string.Format("<{0}>", @from));
//            //Dateの追加
//            if (null == mail.GetHeader("Date"))
//                mail.AddHeader("Date", string.Format("{0}", date));

            //ローカル宛(若しくはローカルファイル)
            if (to.IsLocal(_domainList))
            {
                //ローカル保存の場合は、X-UIDLを追加する
                mail.AddHeader("X-UIDL", uidStr);

                //ヘッダを追加してサイズが変わるので、ここで初期化する
                var mailInfo = new MailInfo(uidStr, mail.Length, host, addr, from, to);

                if (to.IsFile())    //ローカルファイルの場合(直接ファイルにAppendする)
                {
                    if (!_localBox.Save(to, mail, mailInfo))
                    {
                        return(false);
                    }
                }
                else     //ローカルユーザの場合(メールボックスへSaveする)
                {
                    if (!_mailBox.Save(to.User, mail, mailInfo))
                    {
                        return(false);
                    }
                }
                _logger.Set(LogKind.Normal, null, 8, mailInfo.ToString());
            }
            else
            {
                //Toの追加
//                if (null == mail.GetHeader("To")) {
//                    mail.AddHeader("To", string.Format("<{0}>", to));
//                }

                //ヘッダを追加してサイズが変わるので、ここで初期化する
                var mailInfo = new MailInfo(uidStr, mail.Length, host, addr, from, to);
                if (!_mailQueue.Save(mail, mailInfo))
                {
                    _logger.Set(LogKind.Error, null, 9000059, mail.GetLastError());
                    return(false);
                }
                _logger.Set(LogKind.Normal, null, 9, mailInfo.ToString());
            }
            return(true);
        }
Ejemplo n.º 20
0
        private static void KitchenSink()
        {
            String  apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
            dynamic sg     = new SendGrid.SendGridAPIClient(apiKey, "https://api.sendgrid.com");

            Mail mail = new Mail();

            Email email = new Email();

            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            mail.From     = email;

            mail.Subject = "Hello World from the SendGrid CSharp Library";

            Personalization personalization = new Personalization();

            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddTo(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddCc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddCc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddBcc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddBcc(email);
            personalization.Subject = "Thank you for signing up, %name%";
            personalization.AddHeader("X-Test", "True");
            personalization.AddHeader("X-Mock", "True");
            personalization.AddSubstitution("%name%", "Example User");
            personalization.AddSubstitution("%city%", "Denver");
            personalization.AddCustomArgs("marketing", "false");
            personalization.AddCustomArgs("transactional", "true");
            personalization.SendAt = 1461775051;
            mail.AddPersonalization(personalization);

            personalization = new Personalization();
            email           = new Email();
            email.Name      = "Example User";
            email.Address   = "*****@*****.**";
            personalization.AddTo(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddCc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddCc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddBcc(email);
            email         = new Email();
            email.Name    = "Example User";
            email.Address = "*****@*****.**";
            personalization.AddBcc(email);
            personalization.Subject = "Thank you for signing up, %name%";
            personalization.AddHeader("X-Test", "True");
            personalization.AddHeader("X-Mock", "True");
            personalization.AddSubstitution("%name%", "Example User");
            personalization.AddSubstitution("%city%", "Denver");
            personalization.AddCustomArgs("marketing", "false");
            personalization.AddCustomArgs("transactional", "true");
            personalization.SendAt = 1461775051;
            mail.AddPersonalization(personalization);

            Content content = new Content();

            content.Type  = "text/plain";
            content.Value = "Textual content";
            mail.AddContent(content);
            content       = new Content();
            content.Type  = "text/html";
            content.Value = "<html><body>HTML content</body></html>";
            mail.AddContent(content);
            content       = new Content();
            content.Type  = "text/calendar";
            content.Value = "Party Time!!";
            mail.AddContent(content);

            Attachment attachment = new Attachment();

            attachment.Content     = "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12";
            attachment.Type        = "application/pdf";
            attachment.Filename    = "balance_001.pdf";
            attachment.Disposition = "attachment";
            attachment.ContentId   = "Balance Sheet";
            mail.AddAttachment(attachment);

            attachment             = new Attachment();
            attachment.Content     = "BwdW";
            attachment.Type        = "image/png";
            attachment.Filename    = "banner.png";
            attachment.Disposition = "inline";
            attachment.ContentId   = "Banner";
            mail.AddAttachment(attachment);

            mail.TemplateId = "13b8f94f-bcae-4ec6-b752-70d6cb59f932";

            mail.AddHeader("X-Day", "Monday");
            mail.AddHeader("X-Month", "January");

            mail.AddSection("%section1", "Substitution for Section 1 Tag");
            mail.AddSection("%section2", "Substitution for Section 2 Tag");

            mail.AddCategory("customer");
            mail.AddCategory("vip");

            mail.AddCustomArgs("campaign", "welcome");
            mail.AddCustomArgs("sequence", "2");

            ASM asm = new ASM();

            asm.GroupId = 3;
            List <int> groups_to_display = new List <int>()
            {
                1, 4, 5
            };

            asm.GroupsToDisplay = groups_to_display;
            mail.Asm            = asm;

            mail.SendAt = 1461775051;

            mail.SetIpPoolId = "23";

            // This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
            // mail.BatchId = "some_batch_id";

            MailSettings mailSettings = new MailSettings();
            BCCSettings  bccSettings  = new BCCSettings();

            bccSettings.Enable       = true;
            bccSettings.Email        = "*****@*****.**";
            mailSettings.BccSettings = bccSettings;
            BypassListManagement bypassListManagement = new BypassListManagement();

            bypassListManagement.Enable       = true;
            mailSettings.BypassListManagement = bypassListManagement;
            FooterSettings footerSettings = new FooterSettings();

            footerSettings.Enable       = true;
            footerSettings.Text         = "Some Footer Text";
            footerSettings.Html         = "<bold>Some HTML Here</bold>";
            mailSettings.FooterSettings = footerSettings;
            SandboxMode sandboxMode = new SandboxMode();

            sandboxMode.Enable       = true;
            mailSettings.SandboxMode = sandboxMode;
            SpamCheck spamCheck = new SpamCheck();

            spamCheck.Enable       = true;
            spamCheck.Threshold    = 1;
            spamCheck.PostToUrl    = "https://gotchya.example.com";
            mailSettings.SpamCheck = spamCheck;
            mail.MailSettings      = mailSettings;

            TrackingSettings trackingSettings = new TrackingSettings();
            ClickTracking    clickTracking    = new ClickTracking();

            clickTracking.Enable           = true;
            clickTracking.EnableText       = false;
            trackingSettings.ClickTracking = clickTracking;
            OpenTracking openTracking = new OpenTracking();

            openTracking.Enable           = true;
            openTracking.SubstitutionTag  = "Optional tag to replace with the open image in the body of the message";
            trackingSettings.OpenTracking = openTracking;
            SubscriptionTracking subscriptionTracking = new SubscriptionTracking();

            subscriptionTracking.Enable           = true;
            subscriptionTracking.Text             = "text to insert into the text/plain portion of the message";
            subscriptionTracking.Html             = "<bold>HTML to insert into the text/html portion of the message</bold>";
            subscriptionTracking.SubstitutionTag  = "text to insert into the text/plain portion of the message";
            trackingSettings.SubscriptionTracking = subscriptionTracking;
            Ganalytics ganalytics = new Ganalytics();

            ganalytics.Enable           = true;
            ganalytics.UtmCampaign      = "some campaign";
            ganalytics.UtmContent       = "some content";
            ganalytics.UtmMedium        = "some medium";
            ganalytics.UtmSource        = "some source";
            ganalytics.UtmTerm          = "some term";
            trackingSettings.Ganalytics = ganalytics;
            mail.TrackingSettings       = trackingSettings;

            email         = new Email();
            email.Address = "*****@*****.**";
            mail.ReplyTo  = email;

            String ret = mail.Get();

            string  requestBody = ret;
            dynamic response    = sg.client.mail.send.post(requestBody: requestBody);

            Console.WriteLine(response.StatusCode);
            Console.WriteLine(response.Body.ReadAsStringAsync().Result);
            Console.WriteLine(response.Headers.ToString());

            Console.WriteLine(ret);
            Console.ReadLine();
        }