private void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            EmailSendServiceClass emailSendServiceClass = new EmailSendServiceClass(new NetworkCredential {
                UserName = HelperClass.SenderEmail, SecurePassword = passwordBox.SecurePassword
            });

            //Добавляем адресатов
            emailSendServiceClass.AddDestinationEmail(HelperClass.DestinationEmails[0]);
            emailSendServiceClass.AddDestinationEmail(HelperClass.DestinationEmails[1]);
            emailSendServiceClass.AddDestinationEmail(HelperClass.DestinationEmails[2]);

            //Указываем отправителя
            emailSendServiceClass.Sender = HelperClass.SenderEmail;

            //Текст и тема письма
            emailSendServiceClass.Subject = txtSubject.Text;
            emailSendServiceClass.Body    = txtBody.Text;

            //Данные SMTP сервера
            emailSendServiceClass.SmtpServer     = HelperClass.GmailSmtpServer;
            emailSendServiceClass.SmtpServerPort = HelperClass.GmailSmtpServerPort;

            if (emailSendServiceClass.Send() != 0)
            {
                MessageWindow mw = new MessageWindow();
                mw.SetMessage(emailSendServiceClass.LastError);
                mw.SetDescription(emailSendServiceClass.ErrorDescrition);
                mw.Show();
            }
            else
            {
                SendEndWindow sew = new SendEndWindow();
                sew.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            string mail        = "*****@*****.**";
            string strPassword = passwordBox.Password;

            strPassword = passwordBox.Password;

            EmailSendServiceClass emailSender = new EmailSendServiceClass(StaticVariableClass.senderMail, strPassword, mail,
                                                                          subjectBox.Text, mailBox.Text, false, StaticVariableClass.SmtpServer, StaticVariableClass.SmtpPort,
                                                                          true, new SendEndWindow(), new SendErrorWindow());

            emailSender.Send();
        }
Exemplo n.º 3
0
        private void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            EmailSendServiceClass em = new EmailSendServiceClass(tbSubject.Text, tbBody.Text, passwordBox.SecurePassword);

            try
            {
                em.Send();
                SendEndWindow sew = new SendEndWindow();
                sew.ShowDialog();
            }
            catch (Exception ex)
            {
                SendErrorWindow sw = new SendErrorWindow();
                sw.textInfo.Text = $"Невозможно отправить письмо {ex.ToString()}";
                sw.ShowDialog();
            }
        }