Beispiel #1
0
        private void CheckMailPass_Checked(object sender, RoutedEventArgs e)
        {
            if ((Convert.ToBoolean(CheckMailPass.IsChecked)) && (Email.Text != ""))
            {
                PasswordWindow passwordWindow = new PasswordWindow();

                if (passwordWindow.ShowDialog() == true)
                {
                    XenoCode a = new XenoCode();
                    passEmail        = a.RSA_encryption(passwordWindow.Password, login, Email.Text) + "!";
                    Email.IsEnabled  = false;
                    ListV.Visibility = Visibility.Hidden;
                }
                else
                {
                    CheckMailPass.IsChecked = false;
                    Email.IsEnabled         = !false;
                }
            }
        }
        string sendEmail()
        {
            try
            {
                MailMessage mail = new MailMessage();

                string[]   words      = login.Split(new char[] { '@' });
                string     smtp       = "smtp." + words[1];
                SmtpClient SmtpServer = new SmtpClient(smtp);
                mail.From = new MailAddress(login);
                mail.To.Add(AdressEmail.Text);
                mail.Subject = HeaderEmail.Text;

                XenoCode a = new XenoCode();
                if (IsEnc.IsToggled)
                {
                    mail.Body = a.RSA_encryption(BodyEmail.Text, login, AdressEmail.Text) + "&";
                }
                else
                {
                    mail.Body = BodyEmail.Text;
                }
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential(login, pass);
                SmtpServer.EnableSsl   = true;
                ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
                {
                    return(true);
                };
                SmtpServer.Send(mail);
                BodyEmail.Text = AdressEmail.Text = HeaderEmail.Text = "";
                return("good");
            }
            catch (Exception ei)
            {
                DisplayAlert("Ошибка", "Не отправлено!", "ОK");
                return(ei.ToString());
            }
        }
        private void SendClik(object sender, EventArgs e)
        {
            if (checkNullString())
            {
                try
                {
                    string bufNumber = SupportClass.NumberCorrect(AdressEmail.Text);
                    if (IsEnc.IsToggled)
                    {
                        string bufs = "";

                        XenoCode a = new XenoCode();

                        bufs = a.RSA_encryption(BodyEmail.Text, PNumber, bufNumber);

                        ////////////////////////////////////////
                        string[] words  = bufs.Split(new char[] { ' ' });
                        string   header = words[0] + " ";
                        bufs = bufs.Replace(words[0], " ");
                        bufs = bufs.Replace(" ", "");
                        bufs = header + bufs;
                        DependencyService.Get <Interface>().Send(bufNumber, bufs);
                    }
                    else
                    {
                        DependencyService.Get <Interface>().Send(bufNumber, BodyEmail.Text);
                    }

                    BodyEmail.Text = AdressEmail.Text = "";
                }
                catch
                {
                    DisplayAlert("Ошибка", "Не отправлено!", "ОK");
                }
            }
        }
Beispiel #4
0
        private void SendB_Click(object sender, RoutedEventArgs e)
        {
            var textRange = new TextRange(TextMessag.Document.ContentStart, TextMessag.Document.ContentEnd);

            if ((Email.Text.Length > 0) && (textRange.Text.Length > 0) && (Header.Text.Length > 0))
            {
                MailAddress from = new MailAddress(login, "");
                // кому отправляем
                MailAddress to = new MailAddress(Email.Text);
                // создаем объект сообщения
                MailMessage m = new MailMessage(from, to);
                // тема письма
                m.Subject = Header.Text;

                if (Convert.ToBoolean(Encripter.IsChecked))
                {
                    XenoCode a = new XenoCode();

                    m.Body = passEmail + a.RSA_encryption(textRange.Text, login, Email.Text) + "&";
                }
                else

                {
                    m.Body = textRange.Text;
                }
                // адрес smtp-сервера и порт, с которого будем отправлять письмо
                string[]   words = login.Split(new char[] { '@' });
                string     smt   = "smtp." + words[1];
                SmtpClient smtp  = new SmtpClient(smt, 587);
                // логин и пароль
                smtp.Credentials = new NetworkCredential(login, pass);
                smtp.EnableSsl   = true;

                try
                {
                    smtp.Send(m);
                    FlowDocument document  = new FlowDocument();
                    Paragraph    paragraph = new Paragraph();
                    paragraph.Inlines.Add(new Bold(new Run("")));
                    document.Blocks.Add(paragraph);
                    TextMessag.Document = document;

                    if (Convert.ToBoolean(CheckSave.IsChecked))
                    {
                        GoToAddress WindowAddres = new GoToAddress();

                        if (WindowAddres.ShowDialog() == true)
                        {
                            AddressBook ad = new AddressBook(Email.Text, login, pass);
                            ad.Show();
                            CloseCheck = true;
                            this.Close();
                        }
                    }
                    Email.Text = Header.Text = "";
                }
                catch
                {
                    MessageBox.Show("Письмо не отправлено!", "Ошибка");
                }
            }
            else
            {
                MessageBox.Show("Не все поля заполнены!", "Внимание!");
            }
        }