November 2, 2009

Programmatically configure custom contact list value to Outlook 2007 using Web Part

It is inbuilt functionality in SharePoint ‘Action’ menu ‘Connect to outlook’. This functionality used stssync protocol and JavaScript function ‘ExportHailStorm’.

Many times you need some customized functionality like Connect SharePoint contact list to outlook 2007.

I searched many sites but none helped me to find the perfect solution but the show me the way to achieve this.

Here is code for that how to modify inbuilt ‘Connect to outlook’ functionality in under webpart.

To implement this, write function in Creatchildcontrol method in web part.

//code here

Protected override void Creatchildcontrol ()


OutlookButton.Attributes.Add("onClick", "javaScript:OutlookContactSync('Contacts'

,'" + SPContext.Current.Web.Url + "', '/Lists/GeneralContact/'

, '" + SPContext.Current.Web.Lists["GeneralContact"].ID + "'

, 'GeneralContact'

, '" + SPContext.Current.Web.Title + "');");


Protected override void Render (HtmlTextWriter writer)


OutlookButton.RenderControl (writer);

writer. Write (javascriptpath);


Add the following JavaScript function that will be used to call the method you mentioned above.

//JavaScript function

function OutlookContactSync (type, baseUrl, listUrl, listId, listName, siteName)


var outlookURL = encodeURI ('stssync://sts/?ver=1.1&type='+type+'&cmd=add-folder&base-url='+baseUrl+'&list-url='+listUrl+'&guid={'+listId+'}&site-name='+siteName+'&list-name='+listName+'');

Var (outlookURL,'','width=0, height=0');

objWindow.close ();


If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment