/// <summary>
 /// 确定
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Confirm_Click(object sender, EventArgs e)
 {
     SentText?.Invoke(InputTextBox.Text);
     this.Close();//关闭窗口
 }
        private void Send_Click(object sender, RoutedEventArgs e)
        {
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress(eMail));
            message.To.Add(new MailboxAddress(to.Text));
            message.Subject = theme.Text;

            var builder = new BodyBuilder();

            Crypto crypto = new Crypto();

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            string[] temps = crypto.ReturnEncryptRijndaelString(SentText.Text).Split(new string[] { "^&*" }, StringSplitOptions.None);

            string pbKey = keyY.Text;

            //File.ReadAllText("C:/KursachMailClient/" + user + "/Public.txt");  /*"Берём public ключ из базы"*/

            temps[1] = crypto.Encrypt(temps[1], pbKey);   /*Шифруем ключ при помощи алгоритма RSA*/

            string EncryptText = "";

            for (int i = 0; i < temps.Length; i++)    /*Формируем конечную строку*/
            {
                if (i < temps.Length - 1)
                {
                    EncryptText += $"{temps[i]}^&*";
                }
                else
                {
                    EncryptText += temps[i];
                }
            }

            builder.TextBody = EncryptText;

            string temp = "";

            if (AttachFiles.Count != 0)
            {
                for (int i = 0; i < AttachFiles.Count; i++)
                {
                    temp = AttachFiles[i];
                }
                builder.Attachments.Add(temp);
            }

            //foreach (var file in AttachFiles)
            //{
            //    byte[] buff = null;
            //    FileStream fs = new FileStream(file,
            //    FileMode.Open,
            //    FileAccess.Read);
            //    BinaryReader br = new BinaryReader(fs);
            //    long numBytes = new FileInfo(file).Length;
            //    buff = br.ReadBytes((int)numBytes);
            //}

            message.Body = builder.ToMessageBody();

            try
            {
                using (var client = new SmtpClient())
                {
                    client.ServerCertificateValidationCallback = (s, c, h, ex) => true;
                    client.Connect("smtp." + getSuffix(), 465, true);
                    client.Authenticate(eMail, pWord);
                    client.Send(message);

                    using (var _client = new ImapClient())
                    {
                        string IMapAddress = "imap." + getSuffix();
                        _client.ServerCertificateValidationCallback = (s, c, h, z) => true;
                        _client.Connect(IMapAddress, 993, true);
                        _client.Authenticate(eMail, pWord);
                        var folder = _client.GetFolder(SpecialFolder.Sent);
                        folder.Append(message);
                        //folder.MoveTo(message, _client.GetFolder(SpecialFolder.Trash));
                        _client.Disconnect(true);
                    }

                    client.Disconnect(true);

                    MessageBoxResult dialogResult = MessageBox.Show("Отправлено. Закрыть?", "Закрыть?",
                                                                    MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (dialogResult == MessageBoxResult.Yes)
                    {
                        this.Close();
                    }
                    else
                    {
                        to.Clear();
                        theme.Clear();
                        SentText.Clear();
                        attachment.Items.Clear();
                        AttachFiles.Clear();
                        number.Content = "0";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }