Example #1
0
 public OutlookDirectoryInfo(string seed)
 {
     Outlook.Store store = oOutlook.Session.GetStoreFromID(seed);
     folder   = (Outlook.Folder)store.GetRootFolder();
     Name     = folder.Name;
     FullName = folder.FullFolderPath;
 }
Example #2
0
        public MailTable IndexSinglePst()
        {
            Microsoft.Office.Interop.Outlook.Application otlApplication = new Microsoft.Office.Interop.Outlook.Application();
            try
            {
                Outlook.NameSpace otlNameSpace = otlApplication.GetNamespace("MAPI");

                Outlook.Store      otlStore = otlNameSpace.PickFolder().Store;
                System.IO.FileInfo fi       = new System.IO.FileInfo(otlStore.FilePath);
                this.mailTable = new MailTable((new System.IO.FileInfo(otlStore.FilePath)).Name);
                this.mailTable.ModifiedData = fi.FullName + fi.Length.ToString();
                //this.mailTable.BaseTable = GMS.MailTable.getTable(this.mailTable.BaseTable, basetable.Select("StoreID<>'"+otlStore.StoreID.ToString()+"'"));
                try
                {
                    analyseFolder((Outlook.Folder)otlStore.GetRootFolder());
                }
                catch
                {
                }
            }



            catch
            {
            }
            finally
            {
                otlApplication = null;
            }

            return(this.mailTable);
        }
Example #3
0
        public Reporter()
        {
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.White;
            Console.WriteLine("Starting PK Reporter\nWritten by Juan Menendez\n\n");
            Console.ResetColor();

            OutlookApp = GetApplicationObject();
            PKStore = OutlookApp.Session.GetStoreFromID(GetStoreID(OutlookApp.Session.Stores));
            PKAlerts = (Outlook.Folder)PKStore.GetRootFolder();
        }
Example #4
0
        private static void Verificar_Correos(string directory_name, DateTime fec)
        {
            bool verfal;

            verfal = Existe_Buzon();
            if ((verfal == true))
            {
                ns     = ok.Session;
                stores = ns.Stores;
                // cnt debe empezar desde 1 (indice 0 no existe).
                int cnt = 1;
                foreach (Outlook.Store store in ns.Stores)
                {
                    // Si se quiere buscar otro buzon, se debe cambiar el valor en App.Config
                    if (store.DisplayName.ToLower().Contains(ConfigurationManager.AppSettings.Get("busqueda_buzon").ToLower().ToString()))
                    {
                        //MessageBox.Show(store.DisplayName.ToString());
                        break;
                    }
                    else
                    {
                        // Hasta que no entre en el if cnt se incremente (cnt representa las carpetas del buzon por indices).
                        cnt++;
                        // MsgBox(store.DisplayName.ToString)
                    }
                }

                // stores(cnt) es el buz�n el cual se buscar�n los correos a descargar.
                store         = stores[cnt];
                mailboxFolder = store.GetRootFolder();
                folders       = mailboxFolder.Folders;
                for (int j = 1; (j <= folders.Count); j++)
                {
                    folder = folders[j];
                    // folderList += folder.Name + Environment.NewLine
                    if ((folder.Name.ToLower().Equals(directory_name.ToLower())))
                    {
                        // MsgBox(folder.Name, , "Carpeta de Busqueda")
                        SeleccionarCarpeta(folder, fec);
                        j = folders.Count;
                    }
                }

                // MessageBox.Show(folderList, "Lista Outlook")
                //folderList = null;
                Marshal.ReleaseComObject(folder);
            }
        }
        public void List_Of_Folders()
        {
            Outlook.NameSpace  ns         = null;
            Outlook.Stores     stores     = null;
            Outlook.Store      store      = null;
            Outlook.MAPIFolder rootFolder = null;
            Outlook.Folders    folders    = null;
            Outlook.MAPIFolder folder     = null;
            string             folderList = string.Empty;

            try
            {
                Outlook.Application oApp = new Outlook.Application();
                ns         = oApp.Session;
                stores     = ns.Stores;
                store      = stores[1];
                rootFolder = store.GetRootFolder();
                folders    = rootFolder.Folders;

                for (int i = 1; i < folders.Count; i++)
                {
                    folder      = folders[i];
                    folderList += folder.Name + Environment.NewLine;
                    //if (folder != null)
                    //   // Marshal.ReleaseComObject(folder);
                }
                MessageBox.Show(folderList);
            }
            //finally
            //{
            //    if (folders != null)
            //        Marshal.ReleaseComObject(folders);
            //    if (folders != null)
            //        Marshal.ReleaseComObject(folders);
            //    if (rootFolder != null)
            //        Marshal.ReleaseComObject(rootFolder);
            //    if (store != null)
            //        Marshal.ReleaseComObject(store);
            //    if (stores != null)
            //        Marshal.ReleaseComObject(stores);
            //    if (ns != null)
            //        Marshal.ReleaseComObject(ns);
            //}
            catch (Exception ex)
            {
            }
        }
Example #6
0
        /// <summary>
        /// Finds any folder paths containing a particular folderName
        /// </summary>
        /// <param name="folderName"> the folder we are searching for</param>
        /// <param name="inbox"> the inbox we are looking at</param>
        public void findFolder(string folderName, Outlook.Store inbox)
        {
            string paths = "";

            // Get the root folder
            Outlook.Folder root = inbox.GetRootFolder() as Outlook.Folder;

            // get results
            paths = this.EnumerateFolders(root);
            //Console.WriteLine(paths);

            // create a regex for the folderName
            MatchCollection mc = Regex.Matches(paths, ".*" + folderName + ".*");

            if (mc.Count.Equals(0))
            {
                throw new InvalidFolderException("Folder " + folderName + " could not be found.");
            }

            foreach (Match match in mc)
            {
                Console.WriteLine("\t" + match.ToString().Substring(2));
            }
        }
Example #7
0
 private IMailFolder GetRootFolder()
 {
     return(new MailFolderProviderOM(_store.GetRootFolder() as Outlook.Folder));
 }
 /// <summary>
 /// Gets top level (root) folder of the mailbox store
 /// </summary>
 /// <returns>MailFolder object that includes all Folders on top level folder layer</returns>
 public MailFolder GetRootFolder()
 {
     return(new MailFolder(_store.GetRootFolder() as Outlook.Folder));
 }
        public bool TrySetFolder()
        {
            m_rootFolder = m_store.GetRootFolder();

            return(m_rootFolder != null);
        }
        public static void suggestRulesBasedOnCountOfSender(Dictionary <string, int> dictionary)
        {
            Console.WriteLine("hi");

            Outlook.NameSpace  session           = null;
            Outlook.Store      store             = null;
            Outlook.Rules      rules             = null;
            Outlook.MAPIFolder destinationFolder = null;
            Outlook.MAPIFolder rootFolder        = null;
            Outlook.Folders    rootFolderFolders = null;

            Outlook.Rule              rule                     = null;
            Outlook.RuleConditions    ruleConditions           = null;
            Outlook.TextRuleCondition subjectTextRuleCondition = null;

            Outlook.RuleActions          ruleActions    = null;
            Outlook.MoveOrCopyRuleAction moveRuleAction = null;

            string ruleName = string.Empty;

            try
            {
                ruleName = "Move Order Mails Rule";
                //session = Application.Session; // have to correct this error, it was working in 10102017 build when everything was in ThisAddin.cs
                store = session.DefaultStore;
                rules = store.GetRules();

                if (!RuleExist(ruleName, rules))
                {
                    rootFolder = store.GetRootFolder();
                    // destinationFolder = GetFolder(rootFolder.FolderPath + "\\Orders", this);


                    if (destinationFolder == null)
                    {
                        rootFolderFolders = rootFolder.Folders;
                        destinationFolder = rootFolderFolders.Add("Orders");
                    }

                    rule           = rules.Create(ruleName, Outlook.OlRuleType.olRuleReceive);
                    ruleConditions = rule.Conditions;

                    subjectTextRuleCondition      = ruleConditions.Subject;
                    subjectTextRuleCondition.Text = new string[]
                    { "Orders", "orders", "Order", "order" };
                    subjectTextRuleCondition.Enabled = true;

                    ruleActions            = rule.Actions;
                    moveRuleAction         = ruleActions.MoveToFolder;
                    moveRuleAction.Folder  = destinationFolder;
                    moveRuleAction.Enabled = true;

                    ruleActions.DesktopAlert.Enabled = true;

                    rules.Save(true);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.Write(ex.Message);
            }
        }