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); }
public AccountManager() { InitializeComponent(); this.Title = CIV.strings.AccountManager_Title; this.DataContext = this; _settings = ProgramSettings.Load(); RefreshInternetAccess(); ClientList = new ObservableCollection <CIVAccount>(); // Chargement de la liste des modèles de courriel MailTemplateList = new ObservableCollection <string>(); MailFactory mailFactory = new MailFactory(); for (int i = 0; i < mailFactory.MailTemplates.Count; i++) { MailTemplateList.Add(mailFactory.MailTemplates[i].Name); } foreach (CIVAccount account in _settings.Accounts) { ClientList.Add(account); } InitializeBinding(txtUsername, txtUsername.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled"); InitializeBinding(txtQuotaQuantity, txtQuotaQuantity.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled"); InitializeBinding(txtMailRecipients, txtMailRecipients.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled"); chkSendMail.IsEnabled = _settings.EmailSMTP.Active; }
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()); }
public virtual Task SendPasswordRecoveryAsync(string mail, string callbackURL, string token) { CheckInputs(mail, callbackURL, token); MailFactory mailFactory = MailFactory.GetMailFactory <PasswordRecoveryMail>(callbackURL); SendGridMessage msg = PrepareSendGridMessage(mailFactory, mail); return(client.SendEmailAsync(msg)); }
public virtual Task SendRegistrationEmailAsync(string mail, string callbackURL, string token) { CheckInputs(mail, callbackURL, token); MailFactory mailFactory = MailFactory.GetMailFactory <RegistrationActivationMail>(callbackURL); SendGridMessage msg = PrepareSendGridMessage(mailFactory, mail); return(client.SendEmailAsync(msg)); }
public void StartExample() { var mailFactory = new MailFactory(); var mail = mailFactory.CreateProduct("Hilda Ultz", "Jeff Corvin"); mail.Deliver(); var packageFactory = new PackageFactory(); var package = packageFactory.CreateProduct("Rendom Amb", "Merl Corvin"); package.Deliver(); }
public Task HandleMessage(IMessagePayload <IMessageData> baseMessage, JsonSerializerSettings serializerSettings) { switch (baseMessage.Type) { case MessageType.CovidNotification: { var details = baseMessage.Data as CovidNotification; return(_mailer.Send(MailFactory.Create(details.EmailAddress, details.Title, details.Message))); } default: throw new ArgumentException(); } }
public ProductNotify() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); MyBLL = ProductNotifyFactory.CreateProductNotify(); MyProduct = ProductFactory.CreateProduct(); mail = MailFactory.CreateMail(); }
/// <summary> /// 窗体加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditorForm_Load(object sender, EventArgs e) { //初始化邮件配置对象 _config = MailCore.MF.MfMailConfig.GetMailConfig(_vault); if (!String.IsNullOrEmpty(_config.Email) && _config != null) { //发件人 lblSender.Text = MailUtil.FormatToContacts(_config.UserName, _config.Email, true); txtboxSubject.Text = _config.MarkUp + " "; } else { MessageBox.Show("未填写发件人邮箱地址,或邮箱设置未设置正确!"); this.Close(); } var mfMail = MailCore.MF.MessageFromMf.GetMailFromMf(_vault, _objId); _guidDraft = mfMail.Tag; var obj = MailFactory.CreateInstance(_actionType); obj.MailContext = mfMail; obj.MsgConfig = _config; var context = obj.GetMailContext(); if (!String.IsNullOrEmpty(_extAttachPath)) { //bimvision 生成的附件 context.AttachsPath.Add(_extAttachPath); } txtboxSubject.Text += context.Subject; lblSender.Text = context.Sender; txtboxReceiver.Text = context.Recivers; txtboxCC.Text = context.CC; if (context.AttachsPath != null) { foreach (var path in context.AttachsPath) { attachCtrl.AddAttachmentPath(path); } } editor.DocumentText = context.Content; //通讯录数据 SetLinkmanToTreeView(); }
public SendGridMessage PrepareSendGridMessage(MailFactory factory, string email) { var msg = new SendGridMessage() { From = new EmailAddress(mailConfiguration.ApplicationMail), Subject = factory.Subject, PlainTextContent = factory.Content, HtmlContent = factory.Content }; msg.AddTo(new EmailAddress(email)); msg.SetClickTracking(false, false); return(msg); }
private void sendEMail(string sendAdr, string pSenderAddress, string pSubject, string content) { try { MailFactory fac = new MailFactory(); string mailclass = "INBillHunterUtility.INBillHunterUtility"; AbstractMailUtility au = fac.getMailUtility(mailclass.Split(new char[] { '.' })[0], mailclass); au.sendMailHTML("", "127.0.0.1", sendAdr, "", pSenderAddress, pSubject, content); } catch (Exception ex) { log(ex.ToString()); //throw ex; } }
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("邮件设置失败,请检查用户名或密码!"); } }
public ActionResult Forgotpass(string Email) { string key = KeyGenerator.GetUniqueKey(new Random().Next(15, 30)); using (var conn = new MySqlConnection(ConnectionString.Get("EscademyMDB"))) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "INSERT INTO esc_userpasswordreset(PasswordResetToken, PasswordResetExpiration, Email) VALUES (@token, @exp, @mail)"; cmd.Parameters.AddWithValue("@token", key); cmd.Parameters.AddWithValue("@exp", DateTime.UtcNow.AddDays(5)); cmd.Parameters.AddWithValue("@mail", Email); if (cmd.ExecuteNonQuery() >= 1) { // SEND MAIL TO USER var reset_link = "https://www.escademy.com/auth/reset_password?token=" + key; var fileContents = System.IO.File.ReadAllText(Server.MapPath(@"~/App_Data/bf_resetpassword.html")) .Replace("REP_RESET_LINK", reset_link) .Replace("{USERNAME}", "User"); using (var mFactory = new MailFactory()) { mFactory.SendMail( "Password Reset", fileContents, new MailAddress(Email) ); } } } conn.Close(); } ViewBag.mail_sent = true; return(View()); }
/// <summary> /// Envoi un courriel /// </summary> private void SendMail() { if (ProgramSettings.Instance.EmailSMTP.Active && Account.SendMail && !String.IsNullOrEmpty(Account.MailRecipients) && !String.IsNullOrEmpty(Account.MailSubject) && !String.IsNullOrEmpty(Account.MailTemplate)) //if (true) { // Validation que toutes les informations sont disponible pour l'envoi (faille de la v3.0.1) try { SetMessage(CIV.strings.ClientDashboard_MailSending, String.Empty, ScreenMessageType.Normal); MailFactory mailFactory = new MailFactory(); mailFactory.SendMailHTML(new MailTagFormater(Account.Account), ProgramSettings.Instance.EmailSMTP, Account.MailRecipients, Account.MailSubject, Account.MailTemplate, Account.Account); SetMessage(CIV.strings.ClientDashboard_MailSended, Account.MailRecipients, ScreenMessageType.Normal); } catch (SmtpException smtpException) { // Ne pas logguer les erreurs smtp SetMessage(smtpException); } catch (Exception mailException) { LogEngine.Instance.Add(new LogElementBO() { Error = new CivException(mailException) }, ProgramSettings.Instance.AutomaticSendReport); SetMessage(mailException); } } }
public ActionResult Register(User user) { ViewBag.success = false; // ignored for now .. /* * if (!VerifyCapatcha(ConnectionString.Get("capatcha"), Request["g-recaptcha-response"])) * return View(); */ // Verify input if (string.IsNullOrWhiteSpace(user.Email) || string.IsNullOrWhiteSpace(user.Password) || string.IsNullOrWhiteSpace(user.FirstName) || string.IsNullOrWhiteSpace(user.LastName)) { return(View()); } bool verified = false; // INSERT INTO esc_accounts (Email, Password, FirstName, Level) VALUES (@Email, @Password, @FirstName, 1) using (var conn = new MySqlConnection(ConnectionString.Get("EscademyMDB"))) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "INSERT INTO esc_accounts (Email, Password, Level, FirstName, LastName, verified, Created_at, Country) VALUES (@Email, @Password, 1, @FirstName, @LastName, 0, @CreationDate, @Country)"; cmd.Parameters.AddWithValue("@Email", user.Email); cmd.Parameters.AddWithValue("@Password", user.Password.ToSHA512()); cmd.Parameters.AddWithValue("@FirstName", user.FirstName); cmd.Parameters.AddWithValue("@LastName", user.LastName); cmd.Parameters.AddWithValue("@CreationDate", DateTime.UtcNow); cmd.Parameters.AddWithValue("@Country", user.Country); try { if (cmd.ExecuteNonQuery() >= 1) { verified = true; } } catch (MySqlException) { //duplicate entry exception.. } } if (verified) { string key = KeyGenerator.GetUniqueKey(new Random().Next(15, 30)); var reglink = "https://www.escademy.com/auth/confirm_mail?reg=" + key; using (var cmd = conn.CreateCommand()) { cmd.CommandText = "INSERT INTO esc_verificationcodes(VerificationCode, Email) VALUES (@VerificationCode, @Email)"; cmd.Parameters.AddWithValue("@VerificationCode", key); cmd.Parameters.AddWithValue("@Email", user.Email); cmd.ExecuteNonQuery(); } var fileContents = System.IO.File.ReadAllText(Server.MapPath(@"~/App_Data/bf_confirm_mail.html")) .Replace("REP_ACTIVACTION_URL", reglink) .Replace("{FirstName}", user.FirstName); using (var mFactory = new MailFactory()) { mFactory.SendMail( "Welcome to Escademy", //"<html><body><h1>Tak for din registrering hos Escademy.</h1>Tryk på linket forneden for at færdigøre registreringen<br /><a href=\"" + reglink + "\">" + reglink + "</a></body></html>", fileContents, new MailAddress(user.Email) ); } } conn.Close(); if (verified) { return(RedirectToAction("Success")); } else { return(View()); } } }