## Monday, January 30, 2012

### Outlook 2007 Add-in with OTRS

We are using OTRS as ticketing system for support requests, and since it is an internal system only, we wanted to give the opportunity to our employees (requesters) to state their ticket's priority.  The OTRS client interface allows that, but can't add a CC: address, which is wanted by our users, so we decided to try to develop an Office Add-in that would do the job.

I know that we could have used the built-in prorities (Normal, Low, Important) in Outlook, but we wanted 6 levels.  Priorities are important to us because we wanted to have escalation and reports to monitor if the agents are answering and solving tickets in an efficient manner.  So we made 6 SLAs and postmaster filters in OTRS, and the form adds text at the bottom of the message (i.e. SLA=1).  The filter recognizes this text and sets the appropriate header, so the SLA is present in the ticket when it is created.  We also made a GenericAgent job to match the OTRS priority to the SLA of tickets.

First obstacle in the run: The Add-In wouldn't load in Outlook.  The solution: Sign the package.  Not too bad.
Second: There is a limitation in Office 2007 before SP3 that prevents an install of the plugin for all the users (it doesn't allow an Add-in that has registry keys in HKLM to be loaded (If you don't have SP3, there is a hotfix available, see http://blogs.msdn.com/b/vsto/archive/2010/03/08/deploying-your-vsto-add-ins-to-all-users-saurabh-bhatia.aspx).  Fortunately, we now have SP3 everywhere but the fix must be enabled using a registry key. It can't be easy, can it? ;).  Here is the text of the .reg that enables it:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\General]
"EnableLocalMachineVSTO"=dword:00000001

Third: there are prerequisites. First, the Visual Studio Tools for Office Runtime (http://www.microsoft.com/download/en/details.aspx?id=23656) must be installed. It comes as an .exe, so you must run vstor30.exe /x:Extract to extract the content, including its .msi.  I'm  lucky that our Add-in doesn't need the SP1 of VSTOR 3.0 (http://www.microsoft.com/download/en/details.aspx?id=1132) as it comes as an .msp and I don't know how to deploy a .msp in Active Directory.  Second, the Microsoft Office 2007 System Update Redistributable PIA (http://www.microsoft.com/download/en/details.aspx?id=18346) must be installed.  Finally, .NET 3.5 framework must be installed, but it was already on our computers.
Ref: (http://gluegood.blogspot.com/2010/07/namecode-classc-sharp.html).

So, once you have Office 2007 SP3 (or Office 2007 with the hotfix), the .reg is applied, VSTOR and PIA installed, you should be able to install your Add-in.  In our case, it displays a warning asking the user to install or not the Add-In as we haven't found yet what to do to prevent this.

This was how to do it manually, but you'd probably want to deploy using Active Directory.  Here is how I did it:

I have tried deploying in a user GPO, but it didn't work.  The pre-requisites must be installed in a computer GPO, so I decided to put everything in a computer GPO.  I first created a policy object called "LAB Add-In Deploy + Prereq".  I put my lab computer in the security filter and I added 3 software packages (.msi) under Computer Configuration - Software Settings - Software installation.  I created a share with read rights for all authenticated users where I put the .msi packages.  The 3 GPO packages are the VSTO 3.0, the PIAs and the Add-In itself.  Also, I added a startup script in Computer Configuration - Windows Settings - Scripts (Startup/Shudtown) that executes regedit /s on the .reg files to add the needed registry keys.

It is working correctly like this.  When you want to test, you run 'gpupdate /force' on the lab computer, which asks you to reboot, and you answer yes.  Upon reboot, the packages are installed.

What if you want uninstall a package? You right-click on the package, All Tasks, Remove.... You then leave the radio button "Immediately uninstall the software form users and computers" and click OK.  Once the policy has been updated on the computer  (gpupdate /force if needed) and rebooted, the package is uninstalled.

How to upgrade the Add-in? You simply follow the procedure above (uninstall package) and then add a package with the new version.  Once the policy has been updated on the computer  (gpupdate /force if needed) and rebooted, the old package is uninstalled and the new is installed.  Since our Add-in is only 500KB, it is not a problem.  I tried different ways of upgrading (change the .msi, use the upgrade feature in AD (overwriting and not), but this is the only one that really worked for me.

There isn't much documentation on the net about this, so I though it could help a lot of people if I wrote about it.  Feel free to comment if you find mistakes or if you have different experiences with this kind of setup.

Update 1: If you see the add-in twice in Outlook, it is most likely because it is registered twice in the registry: once in HKCU and once in HKLM.