public ActionResult RecoverPasswordResult(RecoverPasswordModelView recover) { if (recover == null) { return(View("RecoverPassword", recover)); } usuario = usuarioDAO.GetByEmail(recover.Email); if (usuario == null) { return(View("RecoverPassword", recover)); } MembershipUser user = Membership.GetUser(usuario.Login); usuario.LastTokenForRecover = Membership.GeneratePassword(12, 1); //Envia o Token de recupeação de senha try { MailFactory email = new MailFactory(usuario.Email, "*****@*****.**", "Recuperação de Login", "Token: " + usuario.LastTokenForRecover); email.Send(); } catch (ArgumentException ex) { } return(View()); }
private void button1_Click(object sender, EventArgs e) { MailProgressForm form = new MailProgressForm(); Thread thread = new Thread(delegate() { string content = FileHelper.readFile("mail.inf"); JObject jobject = (JObject)JsonConvert.DeserializeObject(content); var account = jobject["account"].ToString(); var password = jobject["password"].ToString(); var smtp = jobject["smtp"].ToString(); var port = jobject["port"].ToString(); form.Total = mailList.Items.Count; var index = 0; foreach (object o in mailList.Items) { index++; form.Current = index + 1; MailFactory.Send(account, password, smtp, int.Parse(port), o.ToString(), subjectTxt.Text, contentTxt.Text); } sc.Post(delegate(object obj) { form.Visible = false; }, null); }); thread.Start(); form.ShowDialog(this); }
private void button1_Click(object sender, EventArgs e) { //测试 var account = accountTxt.Text; var password = passwordTxt.Text; var stmp = stmpTxt.Text; var port = portTxt.Text; try { MailFactory.Send(account, password, stmp, int.Parse(port), "*****@*****.**", "邮件设置测试", "邮件设置测试"); var json = "{account:\"" + account + "\",password:\"" + password + "\",smtp:\"" + stmp + "\",port:" + port + "}"; //写入文件 FileHelper.Write("mail.inf", json); this.Visible = false; }catch (Exception ex) { MessageBox.Show("邮件设置失败,请检查用户名或密码!"); } }