Beispiel #1
0
        Mailbag GetMailbag(string template, TemplateModel delivery)
        {
            var mailbag = new Mailbag(delivery.From, delivery.To, delivery.Subject);

            using (var buffer = new TextStream())
            {
                Template[template, delivery].Invoke(buffer);
                mailbag.Contents = buffer.ToString();
            }

            return mailbag;
        }
Beispiel #2
0
        public void Send(Mailbag mailbag)
        {
            var it = mailbag
                .GetMail()
                .GetEnumerator();

            if (!it.MoveNext()) return;
            using (var client = new SmtpClient())
            {
                do
                {
                    Send(client, it.Current);
                } while (it.MoveNext());
            }
        }