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
- Open Windows Explorer
- Right-click on the Local Disk (C:) item and choose NewFolder
- Name the new folder Student
- Right-click on the Student folder and choose NewFolder
- Name the new folder OSC
- Open up the zip file named OSC Hands On Lab.zip in the Lab’s %Office2010DeveloperTrainingKitPath%\Labs\OutlookSocialConnector\Source\Starter folder
- Drag the items in the zip folder into the OSC folder
Exercises
This Hands-On Lab comprises the following exercises:
- Setting up your Development Environment
- Creating a basic OSC Provider
- 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.
- Run Visual Studio 2010 as administrator.
- Open the TestProvider solution.
- Select FileOpenProject/Solution
- Navigate to the TestProvider folder in your Student directory
- Choose TestProvider.sln and click Open
Figure 1
Solution Explorer
- Briefly examine the project assets
- Notice the reference to OutlookSocialProvider. OutlookSocialProvider is the dll that defines the interface that your OSC provider needs to implement.
- The test provider returns static data to the OSC. See the XML files under Resources.
- TestPerson, TestProfile, TestProvider, and TestSessionimplement the required OSC interfaces.
- Build the solution by pressing F6
- Add Outlook to the solution. This is necessary for debugging purposes.
- Right-click on theTestProvider Solution(the top node in the Solution Explorer) and choose AddExisting Project
- Navigate to C:\Program Files (x86)\Microsoft Office\Office14 and select OUTLOOK.EXE.
- Click Open
- Right-click on the OUTLOOK solution in the Solution Explorer and choose Set as StartUp Object
- Right-click on the OUTLOOK solution again and choose Properties
- Set the value of the Debugger Type to Managed (v2.0, v1.1, v1.0)
- Select FileSave All
- Close the OUTLOOK properties window
- 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.
- Right-click on the TestProvider solution (the top node in the Solution Explorer) and choose Configuration Manager
- Set the Active solution platform to Any CPU
- For the TestProvider project, set the Platform to Any CPU
- Click Close
- Right-click on the TestProvider project and select Properties
- On the Build tab, change the Platform target to x86 (the provider needs to match the bitness of Outlook).
- Make sure that Register for COMinterop is checked.
Figure 2
TestProvider properties windows
- Select FileSave 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.
- Review registry key settings
- Using the Solution Explorer in Visual Studio, open up the file named registerProvider.reg in the TestProvider project
- Briefly make note of the registry keys required to register the provider
- 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.
- Create registry keys
- Open up Windows Explorer
- Navigate to the project directory at C:\Student\OSC\TestProvider
- 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.
- Launch MFCMapi.exe which is located in the OSC directory. You can also download this tool from
- Point to Logon and Display Store Table on the Session menu
- 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
- Expand the IPM_SUBTREE node.
- Click the News Feed folder under the root of IPM_SUBTREE.
- Double-clickPR_ATTR_HIDDEN in the property list view for the News Feed folder.
- Uncheck the Boolean check box to unhide the News Feed folder, and then click OK.
Figure 4
MFCMapiTool
- 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.
- In Visual Studio, open the file TestProvider.cs
- Expand the region ISocialProvider Members
- Add a breakpoint in the Load method
Figure 5
TestProvider.cs
- Press F5 to debug the solution
- Verify that Visual Studio stops at the breakpoint shortly after Outlook launches
Figure 6
Breakpoint on TestProvider.cs
- After your breakpoint is hit, press F5 to continue running the solution
- 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.
- Open up another instance of Visual Studio 2010 (Run as Administrator).
- Open the SocialService solution found in your Student directory
- Open the file Program.cs
- 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.
- 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.
- Add SocialServiceProxy.cs to the TestProvider Project
- Copy the file SocialServiceProxy.cs found in the SocialService folder (C:\Student\OSC\SocialService\) to the TestProvider solution folder (C:\Student\OSC\TestProvider).
- In Visual Studio, right-click on the TestProvider project and choose AddExisting Item
- Locate SocialServiceProxy.cs and click Add
- Right-click on References in the Solution Explorer and choose Add Reference
- Click on the .NET tab
- Select System.ServiceModel and click OK
- Add a new class to the TestProvider project named SampleData.cs
- Right-click on the TestProvider project and choose AddClass
- Name the class SampleData.cs and click Add
- Scope the class SampleData as public
- Add a reference to System.Runtime.Serialization. You will use this assembly to access the XmlDictionaryReaderQuotas class necessary for configuring the WCF binding appropriately.
- Import necessary namespaces:
C#
using System.ServiceModel;
using System.Xml;
- 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);
}
- 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;
}
- 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.
- Modify the TestPerson class
- Expand the region ISocialPerson Members
- 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;
}
- 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;
}
- Modify GetFriendsandColleagues (changes in bold)
C#
public string GetFriendsAndColleagues()
{
//string result = Properties.Resources.friends;
string result = SampleData.GetFriends(-1);
return result;
}
- Modify the TestProfile class
- Expand the regions ISocialProfile Members and ISocialPerson members
- 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;
}
- 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;
}
- 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;
}
- 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;
}
- Modify the TestSession class
- ExpandISocialSession Members and ISocialSession2 members
- 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;
}
- 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
- Press F6 to build the solution.
- Make sure the SocialService that you launched in Exercise 2: Task 1 is up and running.
- Press F5 to debug the TestProvider
- In Outlook, press Ctrl + 6 to view the Folder List.
- Click on the contact folder named TestProvider. It should contain two contacts from when you initially ran TestProvider in Exercise 1.
- 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.
- In Visual Studio, press F5 to start debugging your provider
- Once Outlook starts, click on the Add-Ins tab on the ribbon.
Figure 9
Add-ins ribbon tab
- 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
- Right-click on the TestProvider contact folder and choose Delete Folder
- Click on Synch Contacts. Observe that the OSC recreates the folder and synchronizes with the sample social service to add contacts to the folder.
- Click on the Inbox folder
- From the ribbon, select ViewPeople PaneNormal to ensure that the People Pane is visible
- Select any email item
- 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.