in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

echef

From the cluttered (and clustered) brain of Josef Nielsen... A great place for Food, Friends, and... uh... SharePoint of course!

Scripting the "Connect to Outlook" function

You've got to love the "Actions, Connect to Outlook" function in SharePoint lists... Handy for offline viewing of data, nicer GUI for detail entry, etc.  Wouldn't it be nice to automate the connection of these things for a team or a project, or even a division or company?

You can force these connections via script...  They are URL based using the "stssync://" protocol, which depends on the Office WSS services, a shared component of the desktop Office Suite.  You can find the specific call to connect a library to Outlook (much easier to let SharePoint format it that create from scratch) on any of the AllItems.aspx default list pages for a library or list that is "Outlook Friendly", including Tasks, Calendars, and Document Libraries.   View your page source (on an IE browser, as this is not available in other browsers) and looking for the following:

<ie:menuitem id="zz23_OfflineButton"

There is a lot more to this element, which is jammed on a very long line containing about 6 of these <ie:menuitem> elements.  Specifically out of this element you want to get the "onMenuClick" action, which is a javascript call to "ExportHailStorm".  You will need a copy of this function in your script as well, as this is the function that creates the stssync call.  It is located in the init.js file, located in 12\templates\layouts\1033 folder (for US versions)...

The call to ExportHailStorm should look something like the code below, although I've added line breaks to make it readable. 

ExportHailStorm(
   'documents',
   'http:\u002f\u002fsharepoint.company.com\u002fteam\u002fsitename\u002fsandbox',
   '{ac5b6eaf-744a-4f73-a2e1-6e35b81f109e}',
   'Sandbox',
   'Test Files',
   '\u002fteam\u002fsitename\u002fsandbox\u002fTest\u002520Files',
   '','\u002fteam\u002fsitename\u002fsandbox\u002fTest Files');"

You can use these parameters with the MS code in init.js for ExportHailStorm to make your own script with multiple connections for Outlook.  Each call to ExportHailStorm ends in a window.location.href call to the newly created link, which for a document library will look something like this:

stssync://sts/?ver=1.1&type=documents&cmd=add-folder&base-url=http:\u002f\u002fsharepoint.company.com\u002fteam\u002fsitename\u002fsandbox&list-url=\u002fteam\u002fsitename\u002fsandbox\u002fTest\u002520Files&guid={ac5b6eaf-744a-4f73-a2e1-6e35b81f109e}&list-name=Test\u520Files&site-name=Sandbox

These strings can be captured and put in to a simple vbscript or powershell script or even a bat file (run iexplore.exe <url>) and executed in a post setup command, a login script, or embedded in a web page on the intranet (ie, click here to connect standard outlook folders)...

Comments

 

Nick said:

Hi, With this material I was able to track down the fact why a site template I use is not working. It does not have the 'connect to outlook' option under 'actions'. I got the template from the microsoft 40 template download. The template is 'change request management'. If I install a 'tasks' list the in the source I found the component:

<ie:menuitem id="zz18_OfflineButton" type="option" iconSrc="/_layouts/images/MenuPIM.gif" iconScript="BLOCKED SCRIPTofflineBtnImg" onMenuClick="BLOCKED SCRIPTExportHailStorm('tasks','http:\u002f\u002fessix\u002flpi\u002feplan','{5fd2a1eb-50a2-412d-884a-087da812bf60}','EPlan','Tasks','\u002flpi\u002feplan\u002fLists\u002fTasks','','\u002flpi\u002feplan\u002fLists\u002fTasks');" hidden="!offlineBtnText" textScript="BLOCKED SCRIPTofflineBtnText" description="Synchronize items and make them available offline." menuGroupId="400"></ie:menuitem>

In the site template, in the tasks section, this line does not appear. I am assuming this is why i don't get the 'connect to outlook option'. Now I am stuck.

April 21, 2008 10:58 PM
 

josef.nielsen said:

If you are not getting the "Connect to Outlook" option on that particular list, it is probably because that list is not a child of a support type.  A "task-like" list that is a custom list configured for specific purposes will not be able to connect to Outlook, as the required fields may be missing or labeled incorrectly.  The only way around this is to either rewire the template to a standard list type, or to use workflows to push content from and to a standard list (which is definately a work around)...

May 2, 2008 9:52 AM
 

Gary said:

Hey I am configuring Sharepoint 2007 and in my site too I do not see the Actions\Connect to Outlook

... can u explain me how I can add this feature

thanks

June 11, 2008 9:29 PM
 

josef.nielsen said:

Connect to Outlook is a client-side menu option.  The javascript in init.js is a client side look-up to see if you support that function.  If you do not, it does not appear.  

The restrictions for "Connect to Outlook" (to my knowledge) are you must be using a supported list type (Doc Lib, Tasks, Calendar, Contacts), you must be using IE (v.6-8), and you must have the MS SharePoint Services Support Components loaded in your Office install.  SharePoint Services Support Components are a part of the Office Suite, and are installed by default (look under Office Tools in your setup).

June 12, 2008 7:38 AM

About josef.nielsen

I'm a long time computer nerd, living and loving technology wherever I can find it. I've recently shifted from a focus in MS SQL server, MSCS Clustering, and High Availability Engineering to focus on collaboration technologies, including SharePoint 2007. I recently moved from my long-time home in Seattle Washington to Salt Lake City.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts