private async void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            using (var MDContext = new MessageDataContext())
            {
                var wpfEmailer = WPFEmailer.getEmailerInstance(
                    txtUserName.Text,
                    txtTo.Text,
                    txtUserName.Text,
                    txtPassword.Password,
                    txtSubject.Text,
                    txtBody.Text);
                MessageData messageData = new MessageData(ID++, txtUserName.Text, txtBody.Text);
                MDContext.messageDatas.Add(messageData);
                await MDContext.SaveChangesAsync();

                //TODO вынести это в настройки
                //wpfEmailer.Host = txtSMTPServerName.Text;
                //wpfEmailer.Port = Convert.ToInt32(txtSMTPPortNumber.Text);
                try
                {
                    wpfEmailer.SendEmail();
                    MessageBox.Show("Message send successfully.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:" + ex.ToString());
                }
            }
        }
Example #2
0
        private async void MessagesLogUser_Loaded(object Sender, RoutedEventArgs e)
        {
            using (var MDContext = new MessageDataContext())
            {
                var msgList = await MDContext.messageDatas.ToListAsync();

                MessagesList.ItemsSource = msgList;
            }
        }