public void PlayEmailAutomation(object objModel)
        {
            EmailAutomationModel model = objModel as EmailAutomationModel;

            var ea = new EmailAutomation();
            IMailClient client;

            ea.ActionChangedEvent += (s, e) =>
            {
                if (Actionchanged != null)
                    Actionchanged(s, e);
            };

            ea.ProgressValueChangedEvent += (s, e) =>
            {
                if (ProgressValueChanged != null)
                    ProgressValueChanged(s, e);
            };

            if (model.IsProtocolImap)
            {
                client = new ImapClient(model.Hostname, model.Port, model.IsSecure);
            }
            else
            {
                client = new Pop3Client(model.Hostname, model.Port, model.IsSecure);
            }

            ea.MailStatus = model.MailStatus;

            ea.MailCount = model.MailsToDisplay;

            ea.PlayEmailAutomation(client, model.Username, model.Password, model.IsProtocolImap, model.MailBox);

            ea.ProgressValueChangedEvent -= (s, e) =>
            {
                if (ProgressValueChanged != null)
                    ProgressValueChanged(s, e);
            };

            ea.ActionChangedEvent -= (s, e) =>
            {
                if (Actionchanged != null)
                    Actionchanged(s, e);
            };

            ea = null;
        }
예제 #2
0
 private static IMailClient GetMailClient(string hostname, int port, bool useSsl)
 {
     var client = new Pop3Client(hostname, port, useSsl);
     client.LogTrace += (s, e) => Console.WriteLine(e.MessageDelegate());
     return client;
 }
예제 #3
0
 private static IMailClient GetMailClient(Stream stream)
 {
     var client = new Pop3Client(stream);
     client.LogTrace += (s, e) => Console.WriteLine(e.MessageDelegate());
     return client;
 }