private void SetStringValueFilter(FilterType filterType, ToolStripMenuItem toolStripMenuItem, string prompt) { if (filter.Type == filterType) { ClearFilter(); ShowEmails(SelectedProfile); } else { TextInputDialog dialog = new TextInputDialog(); dialog.Title = prompt; if (dialog.ShowDialog() == DialogResult.OK) { ClearFilter(); toolStripMenuItem.Checked = true; filter.Type = filterType; filter.StringValue = dialog.Value; currentFilterToolStripStatusLabel.Text = filterType.ToString() + " [" + filter.StringValue + "]"; ShowEmails(SelectedProfile); } } }
private void SetLongValueFilter(FilterType filterType, ToolStripMenuItem toolStripMenuItem, string prompt, string error) { // Do not clear the Filter if LiteViewer Mode if (filter.Type == filterType && !LiteViewerMode) { ClearFilter(); ShowEmails(SelectedProfile); } else { TextInputDialog dialog = new TextInputDialog(); dialog.Title = prompt; if (dialog.ShowDialog() == DialogResult.OK) { long value = 0; if (long.TryParse(dialog.Value, out value)) { ClearFilter(); toolStripMenuItem.Checked = true; filter.Type = filterType; filter.LongValue = value; currentFilterToolStripStatusLabel.Text = filterType.ToString() + " [" + filter.LongValue.ToString() + "]"; ShowEmails(SelectedProfile); } else { MessageBox.Show(error, "Invalid Value", MessageBoxButtons.OK); } } } }
private void ForwardEmails(IEnumerable <Email> emails) { TextInputDialog dialog = new TextInputDialog(); dialog.Title = "Enter forwarding email addresses"; if (dialog.ShowDialog() == DialogResult.OK) { var smtpSection = ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection; var addresses = dialog.Value.Split(new char[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); using (var smtp = new SmtpClient(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None))) { foreach (var email in emails) { MailMessage message = MailMessage.Load(email.MessageFilePath); foreach (var address in addresses) { smtp.Send(message.ForwardAsAttachment(smtpSection.From, address)); } } } } }