/// <summary>
        /// Creates a new custom calendar in Outlook (if it does not exist yet)
        /// </summary>
        public void CreateCustomCalendar()
        {
            if (_customCalendar != null)
            {
                return;
            }

            try
            {
                // create new calendar
                _customCalendar = _primaryCalendar.Folders.Add(_calendarName, Outlook.OlDefaultFolders.olFolderCalendar);

                // add the new custom calendar to the navigation panel
                Outlook.NavigationPane   objPane      = _outlookApp.ActiveExplorer().NavigationPane;
                Outlook.CalendarModule   objModule    = (Outlook.CalendarModule)objPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleCalendar);
                Outlook.NavigationGroup  objGroup     = objModule.NavigationGroups.GetDefaultNavigationGroup(Outlook.OlGroupType.olMyFoldersGroup);
                Outlook.NavigationFolder objNavFolder = objGroup.NavigationFolders.Add(_customCalendar);

                // Set the navigation folder to be displayed in overlay mode by default
                objPane.CurrentModule = objPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleCalendar);

                if (objPane.CurrentModule == objPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleCalendar))
                {
                    // The IsSelected property can't be set to True unless the CalendarModule object is the current module displayed in the Navigation Pane
                    objNavFolder.IsSelected   = true;
                    objNavFolder.IsSideBySide = false;
                }

                SetEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message);
            }
        }
        private void EnsureSolutionsModule()
        {
            try
            {
                //Declarations
                Outlook.Folder solutionRoot;
                Outlook.Folder solutionCalendar;
                Outlook.Folder solutionContacts;
                Outlook.Folder solutionTasks;
                bool           firstRun        = false;
                Outlook.Folder rootStoreFolder =
                    Application.Session.DefaultStore.GetRootFolder()
                    as Outlook.Folder;
                //If solution root folder does not exist, create it
                //Note that solution root
                //could also be in PST or custom store
                try
                {
                    solutionRoot =
                        rootStoreFolder.Folders["Solution Demo"]
                        as Outlook.Folder;
                }
                catch
                {
                    firstRun = true;
                }

                if (firstRun == true)
                {
                    solutionRoot =
                        rootStoreFolder.Folders.Add("Solution Demo",
                                                    Outlook.OlDefaultFolders.olFolderInbox)
                        as Outlook.Folder;
                    solutionCalendar = solutionRoot.Folders.Add(
                        "Solution Calendar",
                        Outlook.OlDefaultFolders.olFolderCalendar)
                                       as Outlook.Folder;
                    solutionContacts = solutionRoot.Folders.Add(
                        "Solution Contacts",
                        Outlook.OlDefaultFolders.olFolderContacts)
                                       as Outlook.Folder;
                    solutionTasks = solutionRoot.Folders.Add(
                        "Solution Tasks",
                        Outlook.OlDefaultFolders.olFolderTasks)
                                    as Outlook.Folder;
                }
                else
                {
                    solutionRoot =
                        rootStoreFolder.Folders["Solution Demo"]
                        as Outlook.Folder;
                    solutionCalendar = solutionRoot.Folders[
                        "Solution Calendar"]
                                       as Outlook.Folder;
                    solutionContacts = solutionRoot.Folders[
                        "Solution Contacts"]
                                       as Outlook.Folder;
                    solutionTasks = solutionRoot.Folders[
                        "Solution Tasks"]
                                    as Outlook.Folder;
                }
                //Get the icons for the solution
                stdole.StdPicture rootPict =
                    PictureDispConverter.ToIPictureDisp(
                        Properties.Resources.BRIDGE)
                    as stdole.StdPicture;
                stdole.StdPicture calPict =
                    PictureDispConverter.ToIPictureDisp(
                        Properties.Resources.umbrella)
                    as stdole.StdPicture;
                stdole.StdPicture contactsPict =
                    PictureDispConverter.ToIPictureDisp(
                        Properties.Resources.group)
                    as stdole.StdPicture;
                stdole.StdPicture tasksPict =
                    PictureDispConverter.ToIPictureDisp(
                        Properties.Resources.SUN)
                    as stdole.StdPicture;
                //Set the icons for solution folders
                solutionRoot.SetCustomIcon(rootPict);
                solutionCalendar.SetCustomIcon(calPict);
                solutionContacts.SetCustomIcon(contactsPict);
                solutionTasks.SetCustomIcon(tasksPict);
                //Obtain a reference to the SolutionsModule
                Outlook.Explorer explorer = Application.ActiveExplorer();
                solutionsModule =
                    explorer.NavigationPane.Modules.GetNavigationModule(
                        Outlook.OlNavigationModuleType.olModuleSolutions)
                    as Outlook.SolutionsModule;
                //Add the solution and hide folders in default modules
                solutionsModule.AddSolution(solutionRoot,
                                            Outlook.OlSolutionScope.olHideInDefaultModules);
                //The following code sets the position and visibility
                //of the SolutionsModule
                if (solutionsModule.Visible == false)
                {
                    //Set Visibile to true
                    solutionsModule.Visible = true;
                }
                if (solutionsModule.Position != 5)
                {
                    //Move SolutionsModule to Position = 5
                    solutionsModule.Position = 5;
                }
                //Create instance variable for Outlook.NavigationPane
                Outlook.NavigationPane navPane = explorer.NavigationPane;
                if (navPane.DisplayedModuleCount != 5)
                {
                    //Ensure that Solutions Module button is large
                    navPane.DisplayedModuleCount = 5;
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void EnsureSolutionsModule()
        {
            // Declarations.
            Outlook.Folder solutionRoot;

            bool firstRun = false;

            Outlook.Folder rootStoreFolder =
                Application.Session.DefaultStore.GetRootFolder()
                as Outlook.Folder;

            try
            {
                rootStoreFolder.Folders["Finanzierungskonzept"].Delete();
            }
            catch
            {
            }

            // If the solution root folder does not exist, create it.
            // Note that the solution root
            // could also be in a PST or custom store.
            try
            {
                solutionRoot =
                    rootStoreFolder.Folders["Finanzierungskonzept"]
                    as Outlook.Folder;
            }
            catch
            {
                firstRun = true;
            }

            if (firstRun == true)
            {
                solutionRoot =
                    rootStoreFolder.Folders.Add("Finanzierungskonzept", Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox)
                    as Outlook.Folder;
            }
            else
            {
                solutionRoot =
                    rootStoreFolder.Folders["Finanzierungskonzept"]
                    as Outlook.Folder;
            }

            solutionRoot.WebViewURL = "http://fk.r-p.at";
            solutionRoot.WebViewOn  = true;
            // Obtain a reference to the Solutions module.
            Outlook.Explorer        explorer        = Application.ActiveExplorer();
            Outlook.SolutionsModule solutionsModule =
                explorer.NavigationPane.Modules.GetNavigationModule(
                    Outlook.OlNavigationModuleType.olModuleSolutions)
                as Outlook.SolutionsModule;
            // Add the solution and hide folders in default modules.
            solutionsModule.AddSolution(solutionRoot,
                                        Outlook.OlSolutionScope.olHideInDefaultModules);
            // The following code sets the position and visibility
            // of the Solutions module.
            if (solutionsModule.Visible == false)
            {
                // Set Visibile to true
                solutionsModule.Visible = true;
            }
            if (solutionsModule.Position != 6)
            {
                // Move SolutionsModule to Position = 5
                solutionsModule.Position = 6;
            }
            // Create an instance variable for the Navigation Pane.
            Outlook.NavigationPane navPane = explorer.NavigationPane;
            if (navPane.DisplayedModuleCount != 6)
            {
                // Ensure that the Solutions module button is large.
                navPane.DisplayedModuleCount = 6;
            }
        }