Beispiel #1
0
        public void MailAgent_ExtendedDelivery()
        {
            // Make sure that we can queue and deliver several messages over an
            // extended period of time where the background thread will perform
            // multiple polls.

            string folder = Path.Combine(Path.GetTempPath(), "MailAgent");

            using (var agent = new MailAgent(new NetworkBinding(Server), Account, Password, folder, TimeSpan.FromSeconds(1)))
            {
                MailMessage message;

                for (int i = 0; i < 10; i++)
                {
                    message         = new MailMessage("*****@*****.**", "*****@*****.**");
                    message.Subject = string.Format("Test Message #{0}", i);
                    message.Body    = "This is a test of the emergency broadcasting system.\r\nThis is only a test.\r\n";

                    agent.Enqueue(message);
                    Thread.Sleep(2000);
                }

                Thread.Sleep(5000); // Wait 5 seconds to give the agent a chance to deliver the messages.
            }
        }