Esempio n. 1
0
 public static void Send(this MailMessage message)
 {
     using (var client = SimpleSmtpSender.NewClient())
     {
         client.Send(message);
     }
 }
Esempio n. 2
0
        public static void SendAsync <T>(this MailMessage message, Action <T, MailMessage> action, T actionStateArgument)
        {
            var client = SimpleSmtpSender.NewClient();

            client.SendCompleted += (sender, args) =>
            {
                action(actionStateArgument, message);
                client.Dispose();
            };
            client.SendAsync(message, actionStateArgument);
        }
Esempio n. 3
0
        public static void SendAsync <T>(this MailMessage message, Action <T, MailMessage> action, T actionStateArgument)
        {
            var sender = new SimpleSmtpSender();

            sender.SendAsync(message)
            .ContinueWith(t =>
            {
                if (t.IsCompleted)
                {
                    action(actionStateArgument, message);
                }
            }).Wait();
        }