Beispiel #1
0
 private void Msg(params object[] parms)
 {
     foreach (object o in parms)
     {
         MyApp.OutputMessage(this, o);
     }
 }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();
            InitSmtpAuthOptions();

            // Capture output messages
            MyApp.OnOutputMessage += new MyApp.OutputMessageHandler(OnOutputMessage);

            //Try loading settings
            ets = MyApp.LoadOrNew();
            this.DataContext = ets;

            // Update the SMTP Auth field visibility
            UpdateSmtpAuthVisibility();

            MyApp.OutputMessage("Program started");
        }
Beispiel #3
0
        private void Button_SendEmail(object sender, RoutedEventArgs e)
        {
            MyApp.SaveSettings(ets);
            SetSending(true); //Set sending, lock the Send Email button

            //Get ready to send the email in the background
            Task newTask = new Task(() =>
            {
                try
                {
                    MyEmailSender mysender = new MyEmailSender();
                    ets.SmtpAuthPassword   = SmtpPasswordText.SecurePassword; //Grab the password
                    mysender.SendEmail(ets);
                }
                catch (Exception ex)
                {
                    MyApp.OutputMessage("=== ERROR SENDING EMAIL! ===");
                    MyApp.OutputMessage(MyApp.RecurseExceptionAsString(ex));
                }
                finally
                {
                    // Clear out the SMTP auth password
                    if (ets.SmtpAuthPassword != null)
                    {
                        ets.SmtpAuthPassword.Clear();
                    }
                }
            });

            newTask.ContinueWith((task) => {
                SetSending(false); // Re-enable the form
            });

            //Go
            newTask.Start();
        }