How to add presence/pawn to SharePoint contacts list

I have often been asked to add the presence icon and functionality to custom developed web parts or SharePoint pages. As you are probably aware this is a very simple thing to do, the secrect lies in calling the IMNRC jscript function passing in an email address in the rendered html. e.g. IMNRC(<'administrator@somewhere.com'>). You don't really need to know, or probably don't care how this actually works behind the scenes, so in summary; the IMNRC function calls an ActiveX control (called "name.dll") on the users machine which does the work, this control is installed with Office 2003. So developing web parts of custom SharePoint web pages with presence support added is pretty easy.

However, recently I had the requirement to show presence info on the email address field in the out of the box contacts list for WSS sites. I am not 100% sure why this feature was not added by the product team, but I guess it's because your contact list may have email addresses from users outside of your organisation and hence the presence information wouldn't make much sense. Anyway, I set myself the challenge of adding this. In theory it is not that difficult, you need to modify the CAML in the schema.xml for the contacts list to change the HTML that is rendered for the allitems view, i.e. inject the IMNRC function call for the email address field. In theory easy, in practice a little bit of a pain. I have therefore attached the sample CAML that I used in schema.xml for the contacts list. This is the viewbody section in the all contacts view i.e. <View BaseViewID="1">. Remember, this is sample code that you must test fully before deploying. Good luck!

<!-- for each field, if the field is called e-mail then spit out the imnrc function with the raw email address-->

<ViewBody>
<HTML><![CDATA[<TR>]]></HTML>
<Fields>
<HTML><![CDATA[<TD Class="]]></HTML>
<FieldSwitch>
<Expr>
<Property Select="ClassInfo" />
</Expr>
<Case Value="Menu">
<HTML>
<![CDATA[ms-vb-title" height="100%]]></HTML></Case>
<Case Value="Icon">ms-vb-icon</Case>
<Default>
<FieldSwitch>
<Expr><Property Select="Type" /><PresenceEnabled /> </Expr>
<Case Value="UserTRUE">ms-vb-user</Case>
<Default>
<FieldSwitch>
<Expr>
<Property Select="Name" />
</Expr>
<Case Value="Email">ms-vb-user</Case>
<Default>ms-vb2</Default>
</FieldSwitch>
</Default>
</FieldSwitch>
</Default>
</FieldSwitch>
<HTML><![CDATA[">]]></HTML>
<FieldSwitch> <Expr><Property Select="Name"/></Expr>
<Case Value="Email">
<HTML><![CDATA[<table cellpadding="0" cellspacing="0" ID="Tbl_]]></HTML>
<ID/>
<HTML><![CDATA["><tr><td style="padding-right: 3px;"><img border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC(']]></HTML>
<Column />
<HTML><![CDATA[')" id="mnid]]></HTML>
<ID/>
<HTML><![CDATA["></td><td style="padding-top: 1px;" class="ms-vb"> ]]></HTML>
<Field/>
<HTML><![CDATA[</td></tr></table>]]></HTML>
</Case>
<Default><Field/></Default>
</FieldSwitch>
<HTML><![CDATA[</TD>]]></HTML>
</Fields>
<HTML><![CDATA[</TR>]]></HTML>
</ViewBody>

Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm