Showing Presence Information In SharePoint Web Parts
If you’ve visited a SharePoint site, you’ve probably noticed the Messenger-style icons in front of people’s names corresponding the IM status. When you hover the mouse pointer over that icon a lot of additional Messenger and Outlook functionality becomes available: you can send an email to that person, plan a meeting, … Isn’t the SharePoint – Office integration great? A nice example is the Members web part:
Patrick Tisseghem showed already in a demo during the Belgian Dev&IT-Pro Days, how you can use this functionality in your own web parts. but I couldn’t find any information on the net that showed how to do this. Well in fact is quite simple to accomplish this and you can easily test this in a SharePoint site. Just drag and drop a Content Editor web part on a SharePoint site, open the tool pane and click the Source Editor button. In the text entry window type following HTML:
My presence information:<br>
<span>
<img border="0" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC('themail@address.com')" id="IMID1" ShowOfflinePawn=1> Jan Tielens
</span>
The result (the menu showed above pops up when you hover over the image) is:
The magic happens in the IMNRC client-side Javascript function that’s called when the OnLoad event of the image is triggered. This function can be found in the /_layouts/1033/owsbrows.js file. Make sure your put span tags around image and the text, otherwise you’ll end up with some unexpected (but funny) behaviour. Also remember that you need to generate a unique id value for each presence information block. Finally, if you don’t want the offline image to show when the user isn’t online, you can omit the ShowOffLinePawn tag.