是否可以使用主应用程序部署Outlook加载项? [英] Is it posible to deploy an Outlook Add-in with a main Application?

查看:72
本文介绍了是否可以使用主应用程序部署Outlook加载项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy,



我们公司有一个大型ERP应用程序(C#)和一个用VBA制作的小型Outlook插件。每次需要设置新用户时,我们必须在Outlook后台手动安装VBA。现在我们想用C#和VS 2012 Outlook Addin项目创建一个Outlook Addin。



我们希望addin与主ERP应用程序一起自动调整。这是可能的,怎么办呢?

解决方案

等待答案我想出了一些最符合我们需求的解决方案。



他在我们的ERP中创建了一个方法,用于检查外接程序是否在Outlook中安装,如果不是,则启动加载项的安装程序。



 ///< summary> 
///检查是否安装了ERP Outlook加载项,如果没有,则启动安装。
///< / summary>
private static void InstallOutlookAddIn()
{
//获取Outlook应用程序
Outlook.Application application = GetApplicationObject();

//初始化Outlook加载项信息
bool addInInstalled = false;
string AddinName =OutlookCSArchiving;
string SetupPath = @\\\\
as01\public\ICS\Projekte\ERP\Setups\Outlook\setup.exe;

//循环所有Outlook加载项
foreach(app.COMAddIns中的COMAddIn addin)
{
//检查加载项描述是否与out ERP加载项描述
if(addin.Description.ToString()== AddinName)
{
//如果是这样,请设置加载项已安装
addInInstalled =真;

//也会激活加载项,以防它被停用
addin.Connect = true;
}

}

//检查加载项安装布尔值是真还是假(安装了加载项)
if(! addInInstalled)
Process.Start(SetupPath); //如果没有,请通过调用安装文件开始安装

}

///< summary>
///如果没有当前的
///< / summary>获取当前的Outlook应用程序或打开一个新应用程序
///< returns>< / returns>
private static Outlook.Application GetApplicationObject()
{
//初始化应用程序对象
Outlook.Application application = null;

//检查是否有Outlook进程正在运行。
if(Process.GetProcessesByName(OUTLOOK)。Count()> 0)
{
//如果是这样,使用GetActiveObject方法获取进程并将其转换为应用程序宾语。
application = Marshal.GetActiveObject(Outlook.Application)as Outlook.Application;
}
else
{

//如果没有,请创建一个新的Outlook实例。
application = new Outlook.Application();
}

//返回Outlook Application对象。
退货申请;
}





如果有人知道在ERP上删除Outlook加载项的方式让我知道。


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?

解决方案

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.


这篇关于是否可以使用主应用程序部署Outlook加载项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆