Beispiel #1
0
        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);
                    }
                }
            }
        }
Beispiel #2
0
        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));
                        }
                    }
                }
            }
        }