private void button5_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex == -1) { return; } if (MessageBox.Show("Delete the selected cryptomail?", "Delete cryptomail", MessageBoxButtons.YesNo) == DialogResult.Yes) { richTextBox1.Text = ""; MailObjClass MO = (MailObjClass)listBox1.Items[listBox1.SelectedIndex]; DelCryptoMail(Convert.ToInt32(MO.Nummail)); Loadheader(); } }
private void ReadResponseMail(string tag, System.IO.StreamReader sr)//create list mailobject { string response; string s = ""; int i = 0; int j = 0; while ((response = sr.ReadLine()) != null) { // richTextBox1.Text += response + "\r\n"; if (response.IndexOf("From:") == 0) { i = response.IndexOf("<") + 1; j = response.IndexOf(">"); if (i == 0 || j == 0) { s = response.Substring(6); } else { s = response.Substring(i, j - i); } from = s.Trim(); } if (response.IndexOf("Date:") == 0) { datesend = response.Substring(5).Trim(); } if ((response.IndexOf("Subject: Cryptomail") == 0) || (response.IndexOf("Subject: =?UTF-8?B?Q3J5cHRvbWFpbA==?=") == 0)) { //create obj list MailObjClass MO = new MailObjClass(); MO.Nummail = nummail; MO.Datesend = datesend; MO.Mailfrom = from; listBox1.DisplayMember = "Mailfrom"; listBox1.Items.Add(MO); } if (response.StartsWith(tag, StringComparison.Ordinal)) { break; } } }
//create list mailobject private void ReadResponseMail(string tag, System.IO.StreamReader sr) { string response; string s = ""; int i = 0; int j = 0; while ((response = sr.ReadLine()) != null) { // richTextBox1.Text += response + "\r\n"; if (response.IndexOf("From:") == 0) { i = response.IndexOf("<") + 1; j = response.IndexOf(">"); if (i == 0 || j == 0) { s = response.Substring(6); } else { s = response.Substring(i, j - i); } from = s.Trim(); } if (response.IndexOf("Date:") == 0) { datesend = response.Substring(5).Trim(); } if ((response.IndexOf("Subject: Cryptomail") == 0) || (response.IndexOf("Subject: =?UTF-8?B?Q3J5cHRvbWFpbA==?=") == 0)) { //create obj list MailObjClass MO = new MailObjClass(); MO.Nummail = nummail; MO.Datesend = datesend; MO.Mailfrom = from; listBox1.DisplayMember = "Mailfrom"; listBox1.Items.Add(MO); } if (response.StartsWith(tag, StringComparison.Ordinal)) { break; } } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (listBox1.SelectedIndex == -1) { return; } if (e.ClickedItem == contextMenuStrip1.Items[0])//read body mail { //answer if (listBox1.SelectedIndex == -1) { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } int k = 0; MailObjClass MO = (MailObjClass)listBox1.Items[listBox1.SelectedIndex]; richTextBox1.Clear(); richTextBox1.Text += "From: " + MO.Mailfrom + "\r\n"; richTextBox1.Text += "Date: " + MO.Datesend + "\r\n"; richTextBox1.Text += "\r\n"; t = true; sb = new StringBuilder(); ReadCryptoMail(Convert.ToInt32(MO.Nummail)); String bodymail2 = ""; String bodymail = sb.ToString(); //richTextBox2.Text = sb.ToString(); while (bodymail.IndexOf("=") > 0) { k = bodymail.IndexOf("=="); if (k <= 0) { k = bodymail.IndexOf("="); if (k > 0) { bodymail2 = bodymail.Substring(0, k + 1); bodymail = bodymail.Remove(0, k + 1); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } else { bodymail2 = bodymail.Substring(0, k + 2); bodymail = bodymail.Remove(0, k + 2); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } //----------------bodymail; SendMailForm SMF = new SendMailForm(pass, MO.Mailfrom, MO.Datesend + "\r\n" + richTextBox1.Text); SMF.ShowDialog(); } }