Click here to Skip to main content
15,887,989 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hy,

We have a big ERP application (C#) in our company and a small Outlook Add-in made in VBA. Every time a new user needs to be setup we must manually install the VBA in the Outlook background. Now we want to make a Outlook Addin with C# and the VS 2012 Outlook Addin Project.

We want that the addin is automaticaly instaled with the main ERP application. Is that possible and how can it be done?
Posted

1 solution

Well waiting for a answer I figuerd out somethign that is the nearest solution for our needs.

He made a method in our ERP that checks if the Add-In is instaled in Outlook and if it is not it starts the Setup fil of the Add-In.

/// <summary>
        /// Checks if the ERP Outlook Add-In is installed and if not it starts the installation.
        /// </summary>
        private static void InstallOutlookAddIn()
        {
            //Get the Outlook application
            Outlook.Application application=GetApplicationObject();

            //Initialize the Outlook Add-In informations
            bool addInInstalled = false;
            string AddinName = "OutlookCSArchiving";
            string SetupPath = @"\\nas01\public\ICS\Projekte\ERP\Setups\Outlook\setup.exe";

            //Loop trough all Outlook Add-Ins
            foreach (COMAddIn addin  in application.COMAddIns)
            {
                //Check if the Add-in description matches with out ERP Add-In description
                if (addin.Description.ToString() == AddinName)
                {
                    //If so, set that the Add-in is installed
                    addInInstalled = true;

                    //also activate the Add-In, in case it was deactivated
                    addin.Connect = true;
                }

            }

            //Check if Add-In installation boolean is true or false (Add-In installed or not)
            if(!addInInstalled)
                Process.Start(SetupPath); //If not, start the installation by calling the setup file

        }

        /// <summary>
        /// Gets the current Outlook application or opens a new one if there is no current
        /// </summary>
        /// <returns></returns>
        private static Outlook.Application GetApplicationObject()
        {
            //Initialize the application object
            Outlook.Application application = null;

            // Check whether there is an Outlook process running.
            if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
            {
                // If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
            }
            else
            {

                // If not, create a new instance of Outlook.
                application = new Outlook.Application();
            }

            // Return the Outlook Application object.
            return application;
        }


If someone knows a bether way of deploing a Outlook Add-In over an ERP let me know.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900