Пример #1
0
        static void Main(string[] args)
        {
            IEmailProvider         ep = new SmtpEmailProvider("smtp.qq.com", 25, new NetworkCredential("570678569", "q284655"));
            IEmailTemplateEngine   tn = new DotLiquidEmailTemplateEngine();
            IDeliveryConfiguration dc = new DeliveryConfiguration();

            DeliveryService service = new DeliveryService(ep, dc);

            var tos = new List <string>()
            {
                "*****@*****.**",
                "*****@*****.**"
            };
            var message = tn.CreateTextEmail("用户{{ UserName }}兑换了 aa,请及时处理!", new { UserName = "******", From = "*****@*****.**", To = "*****@*****.**", Subject = "邮件主题" });

            message.Cc = tos;
            ep.Send(message);

            service.Start();

            service.Send(message);

            Console.WriteLine("success ");
            Console.Read();
            service.Stop();
        }
Пример #2
0
        public void Can_send_email_with_postmark_provider()
        {
            var engine   = new DotLiquidEmailTemplateEngine();
            var provider = new PostmarkEmailProvider(POSTMARK_SERVER_TOKEN);
            var message  = engine.CreateTextEmail("Hello, {{ YouThere }}!", new { YouThere = "Postmark", From = POSTMARK_FROM_ADDRESS, To = POSTMARK_TO_ADDRESS, Subject = "email test" });

            Assert.IsTrue(provider.Send(message));
        }