private static List <EmailParsingData> GetDeliveryReportList(string filter)
        {
            try
            {
                var           mailBoxContent = new List <EmailParsingData>();
                Outlook.Items folderItems    = null;

                Outlook.MAPIFolder inboxFolder = null;
                foreach (dynamic folder in ThisAddIn.thisApplication.GetNamespace("MAPI").Folders)
                {
                    var subFolders = GpiOutlookWrapper.GetFolder(folder.FolderPath);
                    foreach (Outlook.MAPIFolder subFolder in subFolders.Folders)
                    {
                        if (subFolder.FullFolderPath.Contains("Уведомления о прочтении") &&
                            (subFolder.FullFolderPath.Contains("Канцелярия") || subFolder.FullFolderPath.Contains("kancelaria")))
                        {
                            inboxFolder = subFolder;
                        }
                    }

                    Marshal.ReleaseComObject(subFolders);
                }

                if (inboxFolder == null)
                {
                    return(mailBoxContent);
                }

                folderItems = inboxFolder.Items;
                folderItems.Sort("[CreationTime]", true);

                var item = folderItems.Find(filter);
                while (item != null)
                {
                    var parsingData = new EmailParsingData();
                    parsingData.Subject      = item.Subject;
                    parsingData.ItemClass    = item.MessageClass;
                    parsingData.CreationTime = item.CreationTime;
                    mailBoxContent.Add(parsingData);
                    Marshal.ReleaseComObject(item);
                    item = folderItems.FindNext();
                }

                return(mailBoxContent);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// The email status user control_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void EmailStatusUserControlLoad(object sender, EventArgs e)
        {
            try
            {
                this.NdrDataGridView.AutoGenerateColumns = false;
                this.webBrowser.Url          = new Uri("about:blank");
                this.webBrowser.DocumentText = "<html><body>Ожидание...</body></html>";
                this.Width = 400;

                this.FolderComboBox.Items.Clear();
                var count         = 0;
                var selectedIndex = 0;
                foreach (dynamic folder in ThisAddIn.thisApplication.GetNamespace("MAPI").Folders)
                {
                    var subFolders = GpiOutlookWrapper.GetFolder(folder.FolderPath);
                    foreach (Outlook.MAPIFolder subFolder in subFolders.Folders)
                    {
                        this.FolderComboBox.Items.Add(subFolder);
                        if (subFolder.FullFolderPath.Contains("Канцелярия") && subFolder.FullFolderPath.Contains("Уведомления о прочтении"))
                        {
                            selectedIndex = count;
                        }

                        count++;
                    }

                    Marshal.ReleaseComObject(subFolders);
                }

                this.FolderComboBox.SelectedIndex = selectedIndex;

                this.NdrDataGridView.SelectionChanged += this.EmailStatusDataGridViewSelectionChanged;
                this.MainToolTip.SetToolTip(this.MaxItemNumericUpDown, @"Максимальное число отображаемых отчетов о недоставке");
                this.MainToolTip.SetToolTip(this.UpdateMaxItemButton, @"Установить максимальное число отображаемых отчетов о недоставке");
                this.MainToolTip.SetToolTip(this.FolderComboBox, @"Выбор источника для сканирования отчетов о недоставке");
                this.MainToolTip.SetToolTip(this.FindParentEmailButton, @"Найти исходное письмо");
                this.MainToolTip.SetToolTip(this.NdrDataGridView, @"Отчеты о недоставке (NDR)");
            }
            catch (Exception ex)
            {
                this.InfoListBox.Items.Add("EmailStatusUserControlLoad " + ex.Message);
            }
        }
        /// <summary>
        /// The monitro user control load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void MonitroUserControlLoad(object sender, EventArgs e)
        {
            try
            {
                this.filterParameters                  = FilterParametersData.GetDefault();
                this.FinishDateTimePicker.Value        = this.filterParameters.StartDateTime;
                this.StartDateTimePicker.Value         = this.filterParameters.FinishDateTime;
                this.SubjectContainTextBox.Text        = this.filterParameters.SubjectContain;
                this.NonDeliveryStatusCheckBox.Checked = this.filterParameters.NonDeliveryStatus;
                this.UnknownStatusCheckBox.Checked     = this.filterParameters.UnknownStatus;
                this.DeliveryStatusCheckBox.Checked    = this.filterParameters.DeliveryStatus;

                this.MonitorStatusDataGridView.AutoGenerateColumns = false;

                var dataGridViewColumn = this.MonitorStatusDataGridView.Columns["CreationTimeColumn"];
                if (dataGridViewColumn != null)
                {
                    dataGridViewColumn.DefaultCellStyle.Format = "dd'.'MM'.'yyyy HH:mm:ss";
                }

                this.webBrowser.Url          = new Uri("about:blank");
                this.webBrowser.DocumentText = "<html><body>Ожидание...</body></html>";
                this.Width = 400;

                this.FolderComboBox.Items.Clear();
                var count         = 0;
                var selectedIndex = 0;
                foreach (dynamic folder in ThisAddIn.thisApplication.GetNamespace("MAPI").Folders)
                {
                    var subFolders = GpiOutlookWrapper.GetFolder(folder.FolderPath);
                    foreach (Outlook.MAPIFolder subFolder in subFolders.Folders)
                    {
                        this.FolderComboBox.Items.Add(subFolder);
                        //// if (subFolder.FullFolderPath.Contains("*****@*****.**") && subFolder.FullFolderPath.Contains("Отправленные"))
                        if (subFolder.FullFolderPath.Contains("Отправленные") &&
                            (subFolder.FullFolderPath.Contains("Канцелярия") || subFolder.FullFolderPath.Contains("kancelaria")))
                        {
                            selectedIndex = count;
                        }

                        count++;
                    }

                    Marshal.ReleaseComObject(subFolders);
                }

                this.FolderComboBox.SelectedIndex = selectedIndex;

                this.MonitorStatusDataGridView.SelectionChanged += this.MonitorStatusDataGridViewSelectionChanged;
                this.MainToolTip.SetToolTip(this.FilterButton, @"Показать/скрыть фильтр");
                this.MainToolTip.SetToolTip(this.UpdateButton, @"Обновить список писем");
                this.MainToolTip.SetToolTip(this.FolderComboBox, @"Выбор источника для сканирования отправленных писем");
                this.MainToolTip.SetToolTip(this.StartDateTimePicker, @"Начальная дата");
                this.MainToolTip.SetToolTip(this.FinishDateTimePicker, @"Конечная дата");
                this.MainToolTip.SetToolTip(this.SubjectContainTextBox, @"Фильтр по теме");
                this.MainToolTip.SetToolTip(this.NonDeliveryStatusCheckBox, @"Недоставленный письма");
                this.MainToolTip.SetToolTip(this.DeliveryStatusCheckBox, @"Доставленные письма");
                this.MainToolTip.SetToolTip(this.UnknownStatusCheckBox, @"Нет информации по письму");

                this.MainToolTip.SetToolTip(this.MonitorStatusDataGridView, @"Монитор писем");
            }
            catch (Exception ex)
            {
                this.InfoListBox.Items.Add("EmailStatusUserControlLoad " + ex.Message);
                this.InfoListBox.Items.Add("EmailStatusUserControlLoad " + ex.StackTrace);
            }
        }