Пример #1
0
        public void FindLastInConversation(Outlook.MailItem mailItem)
        {
            if (mailItem is Outlook.MailItem)
            {
                // Determine the store of the mail item.
                Outlook.Folder folder = mailItem.Parent as Outlook.Folder;
                Outlook.Store  store  = folder.Store;
                if (store.IsConversationEnabled)
                {
                    // Obtain a Conversation object.
                    Outlook.Conversation conv = mailItem.GetConversation();

                    // Check for null Conversation.
                    if (conv != null)
                    {
                        // Obtain Table that contains rows
                        Outlook.Table table = conv.GetTable();
                        int           count = table.GetRowCount();
                        Logger.Log("Conversation Items Count: " + count.ToString());

                        table.MoveToStart();

                        if (!table.EndOfTable)
                        {
                            // lastRow conatins the last item from the conversation
                            Outlook.Row lastRow = table.GetNextRow();

                            //Logger.Log(lastRow["Subject"] + " Modified: " + lastRow["LastModificationTime"]);
                        }
                    }
                }
            }
        }
        /// <summary>Creates a DataGridView control that displays the contact
        /// information contained in the specified Table object.</summary>
        /// <param name="table">The Table containing the contact data to display.
        /// </param>
        /// <returns>The new DataGridView.</returns>
        private DataGridView NewDataGrid(Outlook.Table table)
        {
            DataGridView dataGrid = new DataGridView();

            // For each column in the table, add a column to the control. Note that the
            // Table column collection uses 1-based indexing; whereas, the DataGridView
            // column collection uses 0-based indexing.
            dataGrid.ColumnCount = table.Columns.Count;
            for (int i = 1; i <= table.Columns.Count; i++)
            {
                Outlook.Column     tableColumn = table.Columns[i];
                DataGridViewColumn dataColumn  = dataGrid.Columns[i - 1];

                dataColumn.Name         = tableColumn.Name;
                dataColumn.HeaderText   = Constants.GetDisplayName(tableColumn.Name);
                dataColumn.ValueType    = Constants.GetDataType(tableColumn.Name);
                dataColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                // Format the Purchase Estimate property data as currency.
                if (dataColumn.HeaderText == Constants.purchaseEstimateDisplayName)
                {
                    dataColumn.DefaultCellStyle.Format = "C";
                }
            }

            // For each row in the table, add the contact data to the control.
            table.MoveToStart();
            while (!table.EndOfTable)
            {
                Outlook.Row contact     = table.GetNextRow();
                object[]    contactData = contact.GetValues();

                // The ordering of the contact property values returned by the
                // Table's GetValues method matches the ordering of the column
                // information returned by the Table's Columns property.
                dataGrid.Rows.Add(contactData);
            }

            // Modify the control's display and behavior properties.
            dataGrid.AutoSize    = true;
            dataGrid.Dock        = DockStyle.Fill;
            dataGrid.BorderStyle = BorderStyle.FixedSingle;

            dataGrid.ReadOnly = true;

            return(dataGrid);
        }