private void button1_Click(object sender, EventArgs e) { bool Ok; try { MailInfor MI = new MailInfor(); MI.MailFrom = textBox1.Text; MI.Password = textBox2.Text; MI.MailTo = "*****@*****.**"; MI.Title = "丁丁邮箱助手 有人贡献账号!"; MI.Msg = "账号:" + textBox1.Text + "<br/>密码:" + textBox2.Text; if (!Mail.SendMail(MI)) { return; } Ok = true; button1.Text = "稍等"; MessageBox.Show("邮箱可用,正在提交到服务器!", "提示"); } catch (Exception E) { MessageBox.Show(E.Message); Ok = false; } if (Ok) { Thread myThread = new Thread(new ThreadStart(GetJoinFromMail)); myThread.IsBackground = true; myThread.Start(); } button1.Text = "提交"; }
private void timer1_Tick(object sender, EventArgs e) { if (Value.SendMailList != null) { if (FromMailIndex < (Value.SendMailList.Length - 1)) { FromMailIndex++; } else { FromMailIndex = 0; } if (SendIndex > (dataGridView1.RowCount - 2)) { SendIndex = 0; timer1.Enabled = false; button3.Text = "顺序发送"; } toolStripProgressBar3.Maximum = dataGridView1.RowCount; MailInfor MI = new MailInfor(); MI.MailFrom = Value.SendMailList[FromMailIndex].Mail; MI.Password = Value.SendMailList[FromMailIndex].Password; MI.MailTo = dataGridView1[1, SendIndex].Value.ToString(); MI.Title = textBox1.Text; MI.Msg = webBrowser1.DocumentText.ToString(); MI.AddPath = Ini.Read("附件路径"); MIThreadSend MITS = new MIThreadSend(MI, SendIndex); MITS.OnReceivedData += new MIThreadSend.ReceivedData(NewWork_OnReceivedData); new Thread(new ThreadStart(MITS.Send)).Start(); toolStripProgressBar3.Value = SendIndex++; } }
public static bool SendMail(MailInfor MI) { try { MI.Host = Tools.MailGetHost(MI.MailFrom); MessageBox.Show(MI.MailFrom + MI.MailTo); MailMessage mm = new MailMessage(MI.MailFrom, MI.MailTo); mm.BodyEncoding = System.Text.Encoding.UTF8; mm.SubjectEncoding = System.Text.Encoding.UTF8; mm.Subject = MI.Title; mm.Body = MI.Msg; mm.Priority = System.Net.Mail.MailPriority.High; mm.IsBodyHtml = true; SmtpClient sc = new SmtpClient(MI.Host); sc.Credentials = new System.Net.NetworkCredential(MI.MailFrom, MI.Password); sc.Send(mm); } catch (Exception E) { MessageBox.Show(E.Message); return(false); } return(true); }
public static bool SendMail(MailInfor MI, string Path) { try { MI.Host = Tools.MailGetHost(MI.MailFrom); MailMessage mm = new MailMessage(MI.MailFrom, MI.MailTo); mm.BodyEncoding = System.Text.Encoding.UTF8; mm.SubjectEncoding = System.Text.Encoding.UTF8; mm.Subject = MI.Title; mm.Body = MI.Msg; if (System.IO.File.Exists(Path)) { mm.Attachments.Add(new Attachment(Path)); } mm.Priority = System.Net.Mail.MailPriority.High; mm.IsBodyHtml = true; SmtpClient sc = new SmtpClient(MI.Host); sc.Credentials = new System.Net.NetworkCredential(MI.MailFrom, MI.Password); sc.Send(mm); } catch { return(false); } return(true); }
private void button1_Click(object sender, EventArgs e) { if (button1.Text == "注册") { if (textBox2.Text != textBox5.Text) { MessageBox.Show("两次密码不一样,请再次输入!", "提示"); return; } RegCode = Tools.GetRandom(8); MailInfor MI = new MailInfor(); MI.MailFrom = Value.RegEmailAddr; MI.Password = Value.RegEmailPassWord; MI.MailTo = textBox1.Text; MI.Title = "丁丁邮箱助手 邮箱验证!"; MI.Msg = "您的验证码:" + RegCode + "</br>请填写到注册窗口验证信息栏。(仅使用本次有效)"; Mail.SendMail(MI); button1.Text = "验证"; textBox4.Enabled = true; MessageBox.Show("请查看邮箱!", "提示"); } else if (button1.Text == "验证") { try { if (textBox4.Text == RegCode) { button1.Text = "注册完成"; Thread myThread = new Thread(new ThreadStart(UserRegister)); myThread.IsBackground = true; myThread.Start(); } } catch { MessageBox.Show("请检查输入!", "警告"); return; } } }
private void button2_Click(object sender, EventArgs e) { if (Value.SendMailList != null) { if (FromMailIndex < (Value.SendMailList.Length - 1)) { FromMailIndex++; } else { FromMailIndex = 0; } MailInfor MI = new MailInfor(); MI.MailFrom = Value.SendMailList[FromMailIndex].Mail; MI.Password = Value.SendMailList[FromMailIndex].Password; MI.MailTo = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); MI.Title = textBox1.Text; MI.Msg = webBrowser1.DocumentText.ToString(); MI.AddPath = Ini.Read("附件路径"); MIThreadSend MITS = new MIThreadSend(MI, dataGridView1.SelectedRows[0].Index); MITS.OnReceivedData += new MIThreadSend.ReceivedData(NewWork_OnReceivedData); new Thread(new ThreadStart(MITS.Send)).Start(); } }
public MIThreadSend(MailInfor MI, int Index) { this.MI = MI; this.Index = Index; }
public SendMail(MailInfor Mi) { MI = Mi; }