Hands-On Lab

OSC Provider Development

Lab version:1.0.0

Last updated:9/29/2018

Contents

Overview

Exercise 1: Setting up your OSC Project

Task 1 – Configuring the Project Settings in Visual Studio

Task 2 – Registering the Provider

Task 3 – Unhiding the Hidden News Feed Folder

Exercise 1 Verification

Exercise 2: Creating a basic provider

Task 1 – Launching the Sample Social Service

Task 2 – Implementing Calls to the Service in TestProvider

Task 3 – Modifying TestProvider to Call New SampleData Class Rather than Return Static Text

Exercise 2 Verification

Exercise 3: Consuming a provider

Summary

Overview

The Outlook Social Connector (OSC) is a set of new features that help you keep track of friends and colleagues while enabling you to grow your professional network. The OSC brings social views of your networks right to your inbox in a region known as the People Pane. As you read your email, you can view information in the People Pane such as the picture, name, and title of the sender along with a rich aggregated collection of status updates and activities related to the sender.

Because the OSC utilizes an open provider model, you can build providers that work with the OSC to display social network data. In addition to public social network sites, you can also use the OSC provider extensibility to build providers for line-of-business applications or internal corporate web sites and to integrate their services into Outlook.

In this Hands-On Lab, you will gain experience by learning about the basics of OSC provider development.

Objectives

The objective of this Hands-On Lab is to provide you with a foundation for developing your own Outlook Social Connector provider. In particular, you will

  • Learn how to setup your development environment
  • Build and debug a basic OSC provider
  • Understand how to consume an OSC provider in Outlook

System Requirements

The tasks of OSC provider development depend on the specifics of your development environment. The steps in this Hands On Lab assume the following:

  • Microsoft Outlook 2010 (32-bit)
  • Microsoft Visual Studio 2010
  • Microsoft Windows 7 (64-bit)

Setup

This Hands-On lab assumes that the Hands-On lab files are located in a folder named Student\OSC on the C:\ drive. If you haven’t already done so, perform the following steps

  1. Open Windows Explorer
  2. Right-click on the Local Disk (C:) item and choose NewFolder
  3. Name the new folder Student
  4. Right-click on the Student folder and choose NewFolder
  5. Name the new folder OSC
  6. Open up the zip file named OSC Hands On Lab.zip in the Lab’s %Office2010DeveloperTrainingKitPath%\Labs\OutlookSocialConnector\Source\Starter folder
  7. Drag the items in the zip folder into the OSC folder

Exercises

This Hands-On Lab comprises the following exercises:

  1. Setting up your Development Environment
  2. Creating a basic OSC Provider
  3. Consuming an OSC Provider in Outlook

Estimated time to complete this lab: 60minutes.

Starting Materials

This Hands-On Lab includes the following starting materials.

  • TestProvider Solution –This is the Visual Studio project you’ll use to start this exercise. It contains a sample OSC provider implementation that is ready to build & debug.
  • SocialService Solution – This is a Visual Studio project that simulates a basic social service. In exercise two, you will modify the TestProvider solution so that it retrieves data from this service using the Windows Communication Foundation.
  • MFCMapi.exe –MFCMapi.exeis a low-level tool for troubleshooting Exchange and Outlook. You’ll use this tool in exercise one to unhide a hidden Outlook folder.
  • End Solutions\TestProvider – Completed Example.zip –This zip file contains a complete example of the TestProvider solution after modifying it to connect to the SocialService via WCF.

Exercise 1: Setting up your OSC Project

An OSC provider can be written using managed languages such as Microsoft Visual C# or Microsoft Visual Basic, or unmanaged languages such as Microsoft Visual C++. Any tool that can create a COM-visible DLL component can be used to develop an OSC provider. The decision to use a managed or unmanaged language to develop a provider should take into account the download size and dependencies of the provider installation package. In this exercise you will walk through the steps to setup and debug a test provider project. It is important to understand how to setup your project so that you can successfully debug it.

Note:The steps for setting up a development environment vary slightly depending on your operating system and the bitness of Outlook (i.e. 32-bit or 64-bit). See for information applicable to other environments. The steps in this lab assume that you are using a 64-bit version of Windows with a 32-bit version of Outlook.

Task 1 – Configuring the Project Settings in Visual Studio

In order to debug an OSC provider, it is important to configure your project correctly. Otherwise, it may be possible to run your solution, but it may never hit breakpoints in your code. In this task you will perform the initial project configuration settings to properly debug an OSC provider project.

  1. Run Visual Studio 2010 as administrator.
  2. Open the TestProvider solution.
  3. Select FileOpenProject/Solution
  4. Navigate to the TestProvider folder in your Student directory
  5. Choose TestProvider.sln and click Open

Figure 1

Solution Explorer

  1. Briefly examine the project assets
  2. Notice the reference to OutlookSocialProvider. OutlookSocialProvider is the dll that defines the interface that your OSC provider needs to implement.
  3. The test provider returns static data to the OSC. See the XML files under Resources.
  4. TestPerson, TestProfile, TestProvider, and TestSessionimplement the required OSC interfaces.
  5. Build the solution by pressing F6
  6. Add Outlook to the solution. This is necessary for debugging purposes.
  7. Right-click on theTestProvider Solution(the top node in the Solution Explorer) and choose AddExisting Project
  8. Navigate to C:\Program Files (x86)\Microsoft Office\Office14 and select OUTLOOK.EXE.
  9. Click Open
  10. Right-click on the OUTLOOK solution in the Solution Explorer and choose Set as StartUp Object
  11. Right-click on the OUTLOOK solution again and choose Properties
  12. Set the value of the Debugger Type to Managed (v2.0, v1.1, v1.0)
  13. Select FileSave All
  14. Close the OUTLOOK properties window
  15. Verify Project Debug Settings. Prior to debugging, it is critical to verify that your debug settings match the platform on which you are debugging. If there is a mismatch here, your provider will not load in Outlook and you will not be able to debug.
  16. Right-click on the TestProvider solution (the top node in the Solution Explorer) and choose Configuration Manager
  17. Set the Active solution platform to Any CPU
  18. For the TestProvider project, set the Platform to Any CPU
  19. Click Close
  20. Right-click on the TestProvider project and select Properties
  21. On the Build tab, change the Platform target to x86 (the provider needs to match the bitness of Outlook).
  22. Make sure that Register for COMinterop is checked.

Figure 2

TestProvider properties windows

  1. Select FileSave All

Task 2 – Registering the Provider

Before you can debug your provider, you need to add some keys to the registry and register the assembly.

  1. Review registry key settings
  2. Using the Solution Explorer in Visual Studio, open up the file named registerProvider.reg in the TestProvider project
  3. Briefly make note of the registry keys required to register the provider
  4. Note that the entries at the end of the file for HKCU\Software\Microsoft\Office\Outlook\SocialConnector are not specific to the test provider. These keys enable OSC debugging in Outlook.
  1. Create registry keys
  2. Open up Windows Explorer
  3. Navigate to the project directory at C:\Student\OSC\TestProvider
  4. Double-click on the file registerProvider.reg to add the keys in the file to the registry

Task 3 – Unhiding the Hidden News Feed Folder

The OSC uses a folder named News Feed to store information related to status updates or news feeds. This folder is hidden by default. In order to debug an OSC provider, you need to unhide this folder. To do this, you will use the MFCMAPI tool. MFCMAPI is a low-level tool useful for troubleshooting Outlook and Exchange issues.

  1. Launch MFCMapi.exe which is located in the OSC directory. You can also download this tool from
  2. Point to Logon and Display Store Table on the Session menu
  3. In the store table list view, double-click the store that represents the default store for the profile.

Note:To determine your default store, scroll to the right in MFCMapi until you see the heading PR_DEFAULT_STORE. This Boolean property will indicate which store is the default store.

Figure 3

MFCMapi Console

  1. Expand the IPM_SUBTREE node.
  2. Click the News Feed folder under the root of IPM_SUBTREE.
  3. Double-clickPR_ATTR_HIDDEN in the property list view for the News Feed folder.
  4. Uncheck the Boolean check box to unhide the News Feed folder, and then click OK.

Figure 4

MFCMapiTool

  1. Close out of the MFCMAPI tool.

Exercise 1 Verification

Now you have performed all the necessary steps to begin debugging your provider. To verify your work, perform the following actions.

  1. In Visual Studio, open the file TestProvider.cs
  2. Expand the region ISocialProvider Members
  3. Add a breakpoint in the Load method

Figure 5

TestProvider.cs

  1. Press F5 to debug the solution
  1. Verify that Visual Studio stops at the breakpoint shortly after Outlook launches

Figure 6

Breakpoint on TestProvider.cs

  1. After your breakpoint is hit, press F5 to continue running the solution
  2. Close Outlook to stop debugging

Exercise 2: Creating a basic provider

In this exercise you will expand the test provider by replacing static friend and activity data with data that comes from a sample social service. You’ll call this social service using WCF. The social service is an example of how the OSC provider could be used in the enterprise. The sample social service returns a list of sales people as ‘friends’ and returns a sales information (i.e. Joe just closed a $35,500 deal!) as ‘activities’.

Task 1 – Launching the Sample Social Service

In this task you will build and launch a sample social service.

  1. Open up another instance of Visual Studio 2010 (Run as Administrator).
  2. Open the SocialService solution found in your Student directory
  3. Open the file Program.cs
  4. In the SocialService class there is a class variable DBPath – verify that the path to this database is correct. The database should be located in the SocialService directory.
  5. Press F5 to start this service

Figure 7

Social Service started

Task 2 – Implementing Calls to theService in TestProvider

In this task you will perform the necessary modifications to the TestProvider project so that you can call methods in the SocialService service.

  1. Add SocialServiceProxy.cs to the TestProvider Project
  2. Copy the file SocialServiceProxy.cs found in the SocialService folder (C:\Student\OSC\SocialService\) to the TestProvider solution folder (C:\Student\OSC\TestProvider).
  3. In Visual Studio, right-click on the TestProvider project and choose AddExisting Item
  4. Locate SocialServiceProxy.cs and click Add
  5. Right-click on References in the Solution Explorer and choose Add Reference
  6. Click on the .NET tab
  7. Select System.ServiceModel and click OK
  8. Add a new class to the TestProvider project named SampleData.cs
  9. Right-click on the TestProvider project and choose AddClass
  10. Name the class SampleData.cs and click Add
  11. Scope the class SampleData as public
  12. Add a reference to System.Runtime.Serialization. You will use this assembly to access the XmlDictionaryReaderQuotas class necessary for configuring the WCF binding appropriately.
  13. Import necessary namespaces:

C#

using System.ServiceModel;

using System.Xml;

  1. Add a static method called GetClient to the SampleData class. This method is responsible for specifying the binding and endpoint address required to access the SocialService.

C#

private static SocialServiceClientGetClient()

{

//Specify the binding to use for the client.

BasicHttpBinding binding = new BasicHttpBinding();

// Increase the max string content length (default is 8192)

XmlDictionaryReaderQuotasreaderQuotas = new XmlDictionaryReaderQuotas();

readerQuotas.MaxStringContentLength = 524288;

binding.ReaderQuotas = readerQuotas;

//Specify the address to use for the client.

EndpointAddress address =

new EndpointAddress(

"

return new SocialServiceClient(binding, address);

}

  1. Add a static method called GetFriends() to call the GetFriends method exposed by the SocialService:

C#

public static string GetFriends(int ID)

{

string result = "";

SocialServiceClient client = GetClient();

result = client.GetFriends(ID);

client.Close();

return result;

}

  1. Add a static method called GetActivities() to call the GetActivities method exposed by the SocialService:

C#

public static string GetActivities(DateTimestartDate)

{

string result = "";

SocialServiceClient client = GetClient();

result = client.GetActivities(startDate);

client.Close();

return result;

}

Task 3 – ModifyingTestProvider to Call New SampleDataClass Rather than Return Static Text

In this task you will perform the necessary modifications to the TestProvider project so that it calls the appropriate methods in SampleData to return friend and activity information.

  1. Modify the TestPerson class
  2. Expand the region ISocialPerson Members
  3. Modify GetActivities as shown below (changes in bold – note some of the changes include commenting out lines of code)

C#

public string GetActivities(DateTimestartTime)

{

//string result = Properties.Resources.activityFeed;

string result = SampleData.GetActivities(startTime);

Debug.WriteLine(result);

return result;

}

  1. Modify GetDetails as shown below (changes in bold – note some of the changes include commenting out lines of code)

C#

public string GetDetails()

{

//TestProvider only has two friends :(

string result = "";

//if (this.userid.Equals("4667647"))

//{ result = Properties.Resources.friend1; }

//if (this.userid.Equals("5015012"))

//{ result = Properties.Resources.friend2; }

result = SampleData.GetFriends(System.Convert.ToInt32(this.userid));

Debug.WriteLine(result);

return result;

}

  1. Modify GetFriendsandColleagues (changes in bold)

C#

public string GetFriendsAndColleagues()

{

//string result = Properties.Resources.friends;

string result = SampleData.GetFriends(-1);

return result;

}

  1. Modify the TestProfile class
  2. Expand the regions ISocialProfile Members and ISocialPerson members
  3. Modify GetActivitiesOfFriendsAndColleagues as shown below (changes in bold)

C#

public string GetActivitiesOfFriendsAndColleagues(DateTimestartTime)

{

Debug.WriteLine("ISocialProfile::GetActivitiesOfFriendsAndColleagues called startTime = " + startTime.ToString("g"));

//string result = Properties.Resources.activityFeed;

string result = SampleData.GetActivities(startTime);

Debug.WriteLine(result);

return result;

}

  1. Modify GetActivities as shown below (changes in bold)

C#

public new string GetActivities(DateTimestartTime)

{

//string result = Properties.Resources.activityFeed;

string result = SampleData.GetActivities(startTime);

Debug.WriteLine(result);

return result;

}

  1. Modify GetDetails as shown below (changes in bold)

C#

public new string GetDetails()

{

//TestProvider only has two friends :(

string result = "";

//if (this.userid.Equals("4667647"))

//{ result = Properties.Resources.friend1; }

//if (this.userid.Equals("5015012"))

//{ result = Properties.Resources.friend2; }

result = SampleData.GetFriends(System.Convert.ToInt32(this.userid));

Debug.WriteLine(result);

return result;

}

  1. Modify GetFriendsAndColleagues as shown below (changes in bold)

C#

public new string GetFriendsAndColleagues()

{

//string result = Properties.Resources.friends;

string result = SampleData.GetFriends(-1);

return result;

}

  1. Modify the TestSession class
  2. ExpandISocialSession Members and ISocialSession2 members
  3. Modify GetActivities as shown below (changes in bold)

C#

public string GetActivities(string[] emailAddresses, DateTimestartTime)

{

//In this example, we enumerate the emailAddresses

Debug.WriteLine("ISocialSession::GetActivities called for emailAddresses:");

for (int i = 0; i < emailAddresses.GetLength(0); i++)

{

Debug.WriteLine(emailAddresses.GetValue(i));

}

//In this example, we create a dummy set of activities that are static

//In your provider code, lookup activities based on emailAddresses

//string result = Properties.Resources.ActivityFeed;

//string result = Properties.Resources.activityFeed;

string result = SampleData.GetActivities(startTime);

Debug.WriteLine(result);

return result;

}

  1. Modify GetPeopleDetails as shown below (changes in bold)

C#

public string GetPeopleDetails(string personsAddresses)

{

Debug.WriteLine("ISocialSession2::GetPeopleDetails called for personsAddresses: " + personsAddresses);

//return Properties.Resources.friends;

return SampleData.GetFriends(-1);

}

Exercise 2 Verification

  1. Press F6 to build the solution.
  2. Make sure the SocialService that you launched in Exercise 2: Task 1 is up and running.
  3. Press F5 to debug the TestProvider
  4. In Outlook, press Ctrl + 6 to view the Folder List.
  5. Click on the contact folder named TestProvider. It should contain two contacts from when you initially ran TestProvider in Exercise 1.
  6. On the Add-Ins tab of the ribbon, click Sync Contacts. You should now see nine contacts in the TestProvider contacts folder.

Figure 8

TestProvider contacts folder

Exercise 3: Consuming a provider

In exercise 3, you’ll learn how to consume your provider in Outlook and understand all of the ways that the OSC surfaces provider data.

  1. In Visual Studio, press F5 to start debugging your provider
  1. Once Outlook starts, click on the Add-Ins tab on the ribbon.

Figure 9

Add-ins ribbon tab

  1. You enabled the Toolbar Commands on the Add-Ins tab when you added keys to the registry in Exercise 1. Specifically, the ShowDebugButtons key shown below:

[HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\SocialConnector]

"DebugProviders"=dword:00000001

"ShowDebugButtons"=dword:00000001

  1. Right-click on the TestProvider contact folder and choose Delete Folder
  2. Click on Synch Contacts. Observe that the OSC recreates the folder and synchronizes with the sample social service to add contacts to the folder.
  3. Click on the Inbox folder
  4. From the ribbon, select ViewPeople PaneNormal to ensure that the People Pane is visible
  5. Select any email item
  6. In the People Pane, observe the Add button underneath the picture frame. This functionality allows you to add the selected contact to one of your social networks if the provider supports this feature. If you have already added the contact to one of your social networks, instead of an Add button, you’ll see the icon of the social network associated with the contact.