/// <summary>Displays the contact data with the default columns and
        /// does not filter the rows.</summary>
        private void ShowDefaultReport()
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                Outlook.Table contacts = opportunities.GetTable();

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
        /// <summary>Handles the Click event for the form's Customize Columns button.
        /// </summary>
        /// <remarks>Displays the contact data with the addition of the CustomerID
        /// built-in property and the five Sales Opportunity custom properties. Does
        /// not filter the rows.</remarks>
        private void customizeColumnsButton_Click(object sender, EventArgs e)
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                Outlook.Table contacts = opportunities.GetTable();
                AddCustomColumns(contacts);

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
        /// <summary>Handles the Click event for the form's Filter button.</summary>
        /// <remarks>Displays the contact data with the default columns and
        /// filters the rows based on the CompanyName property.</remarks>
        private void filterButton_Click(object sender, EventArgs e)
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                string        criteria = "[CompanyName] = 'Adventure Works'";
                Outlook.Table contacts = opportunities.GetTable(criteria);

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
        /// <summary>Handles the Click event for the form's Customize Columns button.
        /// </summary>
        /// <remarks>Displays the contact data with the addition of the CustomerID
        /// built-in property and the five Sales Opportunity custom properties. Filters
        /// the rows based on the custom Sales Rep property.</remarks>
        private void filterCustomColumnsButton_Click(object sender, EventArgs e)
        {
            Outlook.Folder opportunities = Globals.ThisAddIn.OpportunitiesFolder;
            if (opportunities != null)
            {
                string criteria = string.Format(
                    "[{0}] = 'Karen Berg'", Constants.salesRepDisplayName);
                Outlook.Table contacts = opportunities.GetTable(criteria);
                AddCustomColumns(contacts);

                ShowContactReport(contacts);
            }
            else
            {
                ShowContactReport(null);
            }
        }
Exemple #5
0
        private void DemoTableColumns()
        {
            const string PR_HAS_ATTACH =
                "http://schemas.microsoft.com/mapi/proptag/0x0E1B000B";

            // Obtain Inbox
            Microsoft.Office.Interop.Outlook.Folder folder = MailNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox) as Folder;//Microsoft.Office.Interop.Outlook.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox)as Microsoft.Office.Interop.Outlook.Folder;
            // Create filter
            string filter = "@SQL=" + "\""
                            + PR_HAS_ATTACH + "\"" + " = 1";
            // Must use 'like' comparison for Find/FindNext
            string filter1 = "@SQL="
                             + "\"" + "urn:schemas:httpmail:subject" + "\""
                             + " like '%License Keys - Order%'";

            Microsoft.Office.Interop.Outlook.Table table =
                folder.GetTable(filter,
                                Microsoft.Office.Interop.Outlook.OlTableContents.olUserItems);
            // Remove default columns
            table.Columns.RemoveAll();
            // Add using built-in name
            table.Columns.Add("EntryID");
            table.Columns.Add("Subject");
            table.Columns.Add("ReceivedTime");
            table.Sort("ReceivedTime", Microsoft.Office.Interop.Outlook.OlSortOrder.olDescending);
            // Add using namespace
            // Date received
            table.Columns.Add(
                "urn:schemas:httpmail:datereceived");
            while (!table.EndOfTable)
            {
                Microsoft.Office.Interop.Outlook.Row nextRow = table.GetNextRow();
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(nextRow["Subject"].ToString());
                // Reference column by name
                sb.AppendLine("Received (Local): "
                              + nextRow["ReceivedTime"]);
                // Reference column by index
                sb.AppendLine("Received (UTC): " + nextRow[4]);
                sb.AppendLine();
                System.Diagnostics.Debug.WriteLine(sb.ToString());
            }
        }
Exemple #6
0
        private void searchSentMailUsingTable()
        {
            Outlook.NameSpace nameSpace  = null;
            Outlook.Folder    sentFolder = null;
            Outlook.Table     sentTable  = null;
            Messages          messages   = new Messages(System.Security.Principal.WindowsIdentity.GetCurrent().Name);

            try
            {
                nameSpace  = OutlookApplication.GetNamespace("MAPI");
                sentFolder = nameSpace.GetDefaultFolder(
                    Outlook.OlDefaultFolders.olFolderSentMail) as Outlook.Folder;
                if (sentFolder != null)
                {
                    sentTable = sentFolder.GetTable();
                    sentTable.Columns.Add(TO);
                    sentTable.Columns.Add(CC);
                    while (!sentTable.EndOfTable)
                    {
                        Outlook.Row row = sentTable.GetNextRow();
                        messages.Add(new Message(row[TO], row[CC], null));
                        Marshal.ReleaseComObject(row);
                    }
                    Marshal.ReleaseComObject(sentTable);
                }
            }
            finally
            {
                if (sentFolder != null)
                {
                    Marshal.ReleaseComObject(sentFolder);
                }
                if (nameSpace != null)
                {
                    Marshal.ReleaseComObject(nameSpace);
                }
            }
            if (messages.items.Count() > 0)
            {
                postHistory(messages);
            }
        }
Exemple #7
0
        public IItemData[] GetFiles()
        {
            var outputFiles = new List <IItemData>();

            Outlook.Table folderTable = folder.GetTable("", Outlook.OlTableContents.olUserItems);
            folderTable.Columns.RemoveAll();
            // For property names, see: https://stackoverflow.com/questions/50576645/outlook-mapi-message-class-metadata-in-outlook-2016
            // Open Outlook script editor in developer mode and Press F2 to browse classes and fields
            // https://docs.microsoft.com/en-us/office/vba/outlook/concepts/forms/outlook-fields-and-equivalent-properties
            folderTable.Columns.Add("MessageClass");
            folderTable.Columns.Add("Subject");
            folderTable.Columns.Add("Size");
            folderTable.Columns.Add("LastModificationTime");
            while (!folderTable.EndOfTable)
            {
                try
                {
                    Outlook.Row row = folderTable.GetNextRow();
                    if (row["subject"] == null)
                    {
                        continue;
                    }
                    var messageClass = row["MessageClass"].ToString();

                    var pathParts = new List <string>(this.FullName.Split(new char[] { '/', '\\' }));
                    pathParts.Add(row["Subject"].ToString());
                    var newItem = new ColumnarItemData(pathParts.ToArray(), Columns.ColumnLookup);
                    newItem.SetValue(ITEMSIZE, (int)row["Size"]);
                    var lastModificationTime = row["LastModificationTime"];
                    newItem.SetValue(ITEMDATE, lastModificationTime.ToString());
                    outputFiles.Add(newItem);
                }
                catch (System.Exception e)
                {
                    Debug.WriteLine("Mesage Error: " + e.Message);
                }
            }

            return(outputFiles.ToArray());
        }
Exemple #8
0
        public IItemData[] GetFiles()
        {
            var outputFiles = new List <IItemData>();

            Outlook.Table folderTable = folder.GetTable("", Outlook.OlTableContents.olUserItems);
            folderTable.Columns.RemoveAll();
            folderTable.Columns.Add("MessageClass");
            folderTable.Columns.Add("Subject");
            folderTable.Columns.Add("Size");
            while (!folderTable.EndOfTable)
            {
                Outlook.Row row = folderTable.GetNextRow();
                if (row["subject"] == null)
                {
                    continue;
                }

                var newItem = new ColumnarItemData(new string[] { row["Subject"].ToString() }, Columns.ColumnLookup);
                newItem.SetValue(ITEMSIZE, (int)row["Size"]);
                outputFiles.Add(newItem);
            }

            return(outputFiles.ToArray());
        }