Groove is an excellent Office application for team collaboration. You can also take advantage of the Groove platform from other applications like your VSTO add-ins. Let's take a look at how we can integrate Groove into Outlook using VSTO to create powerful Office Business Applications (OBAs). Groove exposes much of its functionality via a web services API. This groove web service is hosted by the Groove client itself. You can also use web services exposed via the Groove server but I'll save that for another post. In this case we will talk directly to the Groove client using VSTO from an Outlook 2007 add-in.

First start by creating a new C# VSTO Outlook 2007 add-in. The next thing you want to do is create a class library, called GrooveServices, to isolate all of the Groove service code. While this isn't strictly required it will make it easy to reuse Groove services in all of your add-ins.

Adding the Groove Web References

You need to add a web reference to the groove services. But since the Groove client is the service host you can't just browse to it like you would with an .asmx service. So you will need to point to the wsdl file. The wsdl files are in the Groove SDK. After you have downloaded and installed the SDK you will find the wsdl files in C:\Program Files\Microsoft Office 2007 Developer Resources\Microsoft Office Groove 2007 SDK\Lib\XMIs\2.0\wsdl\ folder (if you did a default install). You will need to add a web reference to each one. In Visual Studio Orcas .Net FX 3.5 projects you can only add "Service References". In the June CTP this does not work with the Groove wsdl files but you can still add them as a web reference. Right-Click on the Service References node and choose Add Service Reference then at the bottom of the dialog click on the 'Advance' button. This will open another dialog that will allow you to add a web reference (see the image below). This will bring up the old style add web reference dialog.

Add a web reference to each wsdl file below by pasting in the full path to the wsdl file and rename the service to match the wsdl name without the wsdl extension. For example rename GrooveAccounts.wsdl to GrooveAccounts. This is important because the events helper code in the SDK depends on this naming convention.


The Groove SDK contains a helper file to hook up events using the web services. Add the GrooveEventData.cs file to support events. Located in the C:\Program Files\Microsoft Office 2007 Developer Resources\Microsoft Office Groove 2007 SDK\Lib\DotNet\GrooveEvents folder. OK so now you have all of the Groove services referenced. Add a project reference to the GrooveServices project from your Outlook project and build just to make sure everything is ok before we continue.

Adding the Groove Code

There will be lots of common plumbing code to program Groove. Add a class to the GrooveServices library called GrooveHelper. This class will be where we put common code that may be used by all of our add-ins. There are 2 pieces of information we need to call Groove the first is the service key this is a key that is generated by groove and the second is the port that Groove is listening on, which can be dynamic. Add the following 2 static properties to the GrooveHelper class.


        public static string RequestKey
                Microsoft.Win32.RegistryKey grooveWebServicesRegKey =
                //Request key required for local SOAP access
                string requestKey = grooveWebServicesRegKey.GetValue("LocalRequestKey").ToString();
                return requestKey;

        public static string HostPortAddress
                string localPort;
                string hostPortAddress;
                //Groove registers a port dynamically, which defaults to 9080, but can change
                //Local web service clients must check this registry variable to connect to
                // Groove before each web service call
                Microsoft.Win32.RegistryKey grooveWebServiceHTTPPortRegKey =
                // for localo access, do the following
                localPort = grooveWebServiceHTTPPortRegKey.GetValue("GrooveLocalHTTPPort").ToString();
                hostPortAddress = "http://localhost:" + localPort;
                string grooveHost = hostPortAddress;
                return grooveHost;
List the Groove Accounts
Now you are finally ready to call Groove. Let's start with a simple routine to list all of the accounts that Groove knows about. First add a Ribbon called GrooveRibbon. Add a button called Accounts. We just need a button to trigger the Accounts listing. In the event handler for the button add the following code. Be sure to add a reference to System.Web.Services to your Outlook add-in project.
private void AccountsButton_Click(object sender, RibbonControlEventArgs e)
    //list Groove Accounts    GrooveServices.GrooveAccounts.GrooveAccounts accounts = new GrooveServices.GrooveAccounts.GrooveAccounts();
    accounts.GrooveRequestHeaderValue = new GrooveServices.GrooveAccounts.GrooveRequestHeader();

    accounts.GrooveRequestHeaderValue.GrooveRequestKey = GrooveServices.GrooveHelper.RequestKey;
    accounts.Url = GrooveServices.GrooveHelper.HostPortAddress + "/GWS/Groove/2.0/Accounts/";

    //Read the accounts
    GrooveServices.GrooveAccounts.Account2[] theAccounts = accounts.Read2();

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < theAccounts.Length; i++)
        sb.AppendLine("Account " + i);

        GrooveServices.GrooveAccounts.Account2 acct = theAccounts[i];
        string accountName = acct.Name;
        string accountURI = acct.URI;
        string contactsURI = acct.Contacts;
        string messagesURI = acct.Messages;

        sb.AppendLine(accountName + " " + accountURI + " " + contactsURI + " " + messagesURI);

        for (int j = 0; j < acct.Identities.Length; j++)
            GrooveServices.GrooveAccounts.Identity2 ident = acct.Identities[j];
            string identityName = ident.Name;
            string identityURL = ident.URI;
            string spacesURI = ident.Spaces;

            sb.AppendLine("identity " + j + " " + identityName + " " + identityURL + " " +spacesURI);


 Run the project. This will display all of the accounts in a messagebox.

In upcoming posts we will refactor this code into the GrooveHelper class so that we can use the account information to get to the actual workspaces. Much of this code is taken directly from the SDK help so you should be able to dig around the other parts now that the services are all hooked up. As we continue to build this sample you will see how we can integrate this more tightly with Outlook. But for now you have the basics to begin Groove'n in Outlook.