Custom Calendar Providers for Outlook 2007

So if you were using Stephen Toub'sCustom Calendar Provider sample for Outlook 2003, and you are testing out the awesome new Outlook 2007 features, you may have noticed that the code sample he provided doesn't work any more. Stephen is planning to update the article for 2007 eventually, but until then, here's the fix.

The GetList web service method is supposed to return a <Fields> node filled with <Field> nodes that describe each field in that list, including type information, display names, read-only properties, etc. In the sample above, Stephen is not returning the <Fields> node as a part of the response. The reason is that Outlook 2003 ignored this information when it was performing the sync. Outlook 2007 is a little more intelligent in this regard and it does need this information returned. It's not a big deal when linking to a SharePoint Events list, because SharePoint always returns that data. In an effort to keep the code simple, Stephen ignored it.

So the answer is that we need to add that information back in. So what you'll want to do is edit the WssListResponse.cs file as follows:

You'll notice that I have commented out a few lines in this method. There are probably more lines that can be commented out. We're not returning all the information that SharePoint would return, but it's not all useful to Outlook, so why clog the ethernet lines with useless data?!

Anyway, once you've made those modifications, you can recompile the web application and you should be golden!

It occurred to me that Outlook 2007 was launched in November, so there was likely a later version than my beta 2 build 4017. I am now running with build 4518 and am pleased to say that your changes work :o)

Not only do they work, but I was able to apply them to Stephen Toub’s OutlookContactProvider too, and am serving up my own custom data.

I’m told Outlook 2007 supports writing to WSS lists, so how do you specify that the contacts/events folder is writable, which presumably would then show the outlook edit form, and result in calls to UpdateListItems(). At the moment if I try to make changes Outlook tells me "This SharePoint list is read-only in Outlook".

What I did for the example above was that I called the GetList web service with javascript, and got the response back and examined it. I just used a standard Events list with no added columns from a standard Team site. You could probably do the same thing with a standard Contacts list.

You will have to figure that out in a way that makes sense for what you’re trying to do. You could extend that method to take an additional parameter that tells you what type of list you are asking for and then construct the XML data based on that, or you could just store the XML for the different types of lists separately in an XML file, load them up and return them. This was just a hard-coded sample to show you the method to use in taking advantage of the stssync capabilities of Outlook. It’s up to you to run with it and test it out.

If you’re asking how to get the list data for a Contacts list, just call the GetList web service on a standard contacts list in SharePoint and observe the return value. SharePoint is going to return all the data about that list including field information and View information. At this point, it’s not important to include the View information, because Outlook doesn’t care about it. In fact, the reason that I created this post was that in Outlook 2003, it didn’t even care about the Fields collection, it just assumed certain fields were present. Outlook 2007 got a little smarter about it and started paying attention to the Fields that GetList returns. That’s why we needed to add that node into the response that our web service is returning to include the Fields node.

What are the chances of investigating for us the minimal requirements for reading contacts into outlook using the syssync 1.2 protocol as opposed to this 1.0 method. (i’d LOVE to have two way sync happening)

I have done everything i can to handcraft the xml copied from a sample web request from a sharepoint 2007 site. Cant seem to get it happening (GetList seems to be the first issue in replicating).

I combined Calendar and Contacts into one ASP.NET 2.0 application and added the tweaks for OL 2007. Tested with 2003 went perfectly OK, test with 2007 is still a todo. I can post the code, if there is interest but I’d like to add a couple of aditional calendar fields. Has anyone found the definitions for the ‘show as’ (Free, Busy, …) and Category (I want to set the colors)?

I would like to know if it’s possible to made with post folders. I have an Sharepoint 2007 discussion list and I want to edit the default view to include more fields present in Sharepoint. Is it possible to this in same way as for contacts.

Francois, I’m not sure what you’re asking. Are you asking if it’s possible to use stssync with a Discussion List to display the items in your Outlook contacts folder, or are you asking how to create a custom view in SharePoint?

If the former, I suppose it’s possible as long as you handle the mapping from the different fields into fields that Outlook would expect to see for a contact.

If the latter, then I’d point you to http://msdn.microsoft.com/sharepoint. Look for the documentation on CAML. You can create and edit SharePoint views with CAML, but it is not easy at all. It may be easier to use a tool such as SharePoint Designer or FrontPage. I’m not sure if this answers your question though.

To the best of my knowledge, that is correct, Stefan. And to answer your question, there’s not a way to directly have the stssync put appointments into the calendar. Outlook creates a wrapped PST specifically for SharePoint synchronization. The only way you’d be able to do it is if you then have code that synchronizes between your calendar and the SharePoint events calendar in the PST. This is not an easy undertaking. If you just need the one-way sync, you may be able to just wipe/replace from a new calendar folder in your mailbox. That would be easier code to write, but only allows for one-way sync, and any changes made by the end user would be erased at the next sync.

Hi Wilson, remember that there are a fixed set of fields that are synchronized. If the field is not part of the original schema for the Contacts list, then it may not be automatically synchronized. The list of fields increases with Outlook 2007, but it’s still fixed. Check out my latest blog entry where we have published exactly how to build these types of services. There may be more detail in the specification. (I haven’t had time to read it yet myself.) 🙂