public void ReadToConfig() { config = new EmailServerConfig( tbServer.Text.Trim(), tbAccount.Text.Trim(), tbPassw0rd.Text.Trim(), Convert.ToInt32(tbPort.Text.ToString()), cbSsl.Checked, tbEmailAddress.Text.Trim(), tbDisplayName.Text.Trim(), tbSubject.Text, tbContent.Text, tbTo.Text); }
public void Load() { //LoadTemp ReadToConfig(); var configPath = AppDomain.CurrentDomain.BaseDirectory + @"/Config/"; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } if (File.Exists(configPath + @"/Temp.xml")) { var str = File.ReadAllText(configPath + @"/Temp.xml"); config = str.XmlDeSerialize <EmailServerConfig>(); SetToUi(); } }
private void 加载配置_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; var result = open.ShowDialog(); if (string.IsNullOrEmpty(open.FileName)) { return; } else { var str = File.ReadAllText(open.FileName); config = str.XmlDeSerialize <EmailServerConfig>(); SetToUi(); } }
private void RegisterSettings() { FlexKids flexKidsConfig = _config.GetSection("FlexKids").Get <FlexKids>(); GoogleCalendar googleCalendarConfig = _config.GetSection("GoogleCalendar").Get <GoogleCalendar>(); Smtp smtpConfig = _config.GetSection("SMTP").Get <Smtp>(); NotificationSubscriptions notificationSubscriptions = _config.GetSection("NotificationSubscriptions").Get <NotificationSubscriptions>(); var staticEmailServerConfig = new EmailServerConfig( smtpConfig.Host, smtpConfig.Port, smtpConfig.Username, smtpConfig.Password, smtpConfig.Secure); _container.RegisterInstance(staticEmailServerConfig); var staticGoogleCalendarConfig = new GoogleCalendarConfig( googleCalendarConfig.Account, googleCalendarConfig.CalendarId, googleCalendarConfig.PrivateKey); _container.RegisterInstance(staticGoogleCalendarConfig); var staticEmailConfig = new EmailConfig( new MailAddress(notificationSubscriptions.From.Email, "FlexKids rooster"), notificationSubscriptions.To.Select(x => new MailAddress(x.Email, x.Name)).ToArray()); _container.RegisterInstance(staticEmailConfig); var staticFlexKidsHttpClientConfig = new FlexKidsHttpClientConfig( flexKidsConfig.Host, flexKidsConfig.Username, flexKidsConfig.Password); _container.RegisterInstance(staticFlexKidsHttpClientConfig); }
public Configuration() { Email = new EmailServerConfig(); Sheet = new SheetConfig(); }
/// <summary> /// create SmtpClient, create mail message, and send message. Catches exceptions and puts them in QueueManager.ExceptionStack. /// </summary> /// <param name="e"></param> /// <param name="cfg"></param> /// <returns></returns> public bool SendEmail(Email e, EmailServerConfig cfg) { try { e.emailFrom = cfg.OutgoingAccount; var client = new SmtpClient(cfg.HostName, cfg.Port) { Credentials = new NetworkCredential(cfg.OutgoingAccount, cfg.OutgoingPassword), EnableSsl = cfg.EnableSSL }; var msg = new MailMessage(e.emailFrom, e.emailTo); if (e.attachment != null) { var a = Attachment.CreateAttachmentFromString(e.attachment, e.attachmentContentType); a.Name = "Order.html"; msg.Attachments.Add(a); } msg.Subject = e.subject; msg.Body = e.body; client.Send(msg); e.statusID = Email.iSent; // record sent sentStack.Push(e); } catch (Exception ex) { // don't log the repeating message if (exceptionStack.Count() == 0 || exceptionStack.Peek().Message != ex.Message) { exceptionStack.Push(ex); } e.statusID = Email.iTransmitError; } finally { e.lastAttempt = DateTime.Now; e.transmitAttempts += 1; } return true; }
/// <summary> /// Get emails from EmailService and calle SendMail to send emails /// </summary> /// <param name="cfg"></param> public void ProcessQueue(EmailServerConfig cfg) { exceptionStack = new Stack<Exception>(); sentStack = new Stack<Email>(); // var emaillist = serv.GetEmailsToSend(); foreach (var e in emaillist) { SendEmail(e, cfg); } db.Commit(); }
public FrmBatchSend(EmailServerConfig config) { InitializeComponent(); this._config = config; }