The great thing about having children is being pseudo-tuned in to pop culture. As I got into the car with my teenager the other day, we commenced our daily battle for control of the radio. Since I was driving and paying attention to the road, he won and I was hostage to his musical whims. This song came on, which is the title of this article, and it was catchy. My mind, never far from SharePoint, played the title over and over. Later that day, as I was working to make a few technologies work together, it clicked. Several lessons ensued.

The item I was trying to make work is a commonly requested feature: When a user clicks on an e-mail link in a list of articles and has the default e-mail reader pop up with passed-in information in the subject and body. The answer on how to do this is use XSL, JavaScript and Mailto.

Everybody talks. Here was my first issue:

The e-mail image is wrapped in an href attribute embedded with a JavaScript call that would eventually have two parameters. The XSL code was similar to this:
<a><xsl:attribute name=”href”>javascript:SendEmail(<xsl:value-of select=”@Link”/>);</xsl:attribute><img src=”source”/></a>

How to pass a link to JavaScript. This should be easy, except that the folks who wrote the site before me did not create their lists/libraries without spaces. While I have a lot of pet peeves, one of the only things I am anal about in SharePoint is creating anything without the _0x200_, otherwise known as a space. Create columns, lists or libraries without spaces. Put the space in after the object is created.

The answer to the first issue was to add single quotes around the @Link. However, you cannot just place quotes there. You have to use a concat statement and the representation of quotes. After some research, I got the following to work:
<xsl:value-of select=”concat(‘&quot’,@Link,’&quot;’)”/>

Everybody talks. XSL was speaking to JavaScript and passing in the link. To render the default reader, I used the Mailto functionality. Mailto is an Internet standard: RFC 2368. The problem with Mailto is that is only renders text, not HTML. This is a big issue because I was passing in a link I wanted to be clickable. It was rendering as follows: http://www.domain.com/HMC Document/article1.aspx

That darn space again! I tried a lot of different options, but it was my project manager who had seen something like this in the past. He suggested surrounding the link with brackets as so:
body = “<”+link+”>”;
Window.location.href=mailto:?Subject=+subject+”&amp;body=”+body;

This worked fantastically. I did not have to write server-side code and I did not have to recreate the library without spaces and move all that data; it’s metadata and associated references across the site. Everybody talks.

The moral of this story is not just showing you some good technical content (like I just did), but that everybody talked. A problem was solved not just technically but because project management and developers talked and listened. I’ve been doing this 20 years and I know that I don’t know everything.

My son does know some things too! As a Dad, I am 20 years in, and that song is catchy!

Peter Serzo is a published author of the “SharePoint 2010 Administration Cookbook,” a founder of the SouthEastern SharePoint group, a speaker, and SharePoint Architect for High Monkey Consulting. Peter has been in the IT industry for 20 years. He has extensive experience with SharePoint implementing business solutions for several enterprise organizations over the past seven years.