Share via


SharePoint 2010: Presence Indicator

Following is the code snippet to display the presence indicator for users in SharePoint. We can get the sipAddres used in the code for the users from the below three locations 

  • Userprofile property SipAddress or
  • Userprofile property WorkEmail or 
  • SiteUserInfoList list
if (!string.IsNullOrEmpty(sipAddress))
            {
                /*Generate HTML for presence indicator*/
                strPresence = string.Concat(
                                            "<span id=\"PresenceLink"
                                            , sipAddress
                                            , "\">"
                                            , "<span><img name=\"imnmark\" border=\"0\" height=\"12\" src=\"/_layouts/images/imnhdr.gif\" onload=\"IMNRC('"
                                            , sipAddress
                                            , "')\" ShowOfflinePawn=\"1\" style=\"padding-right: 3px;\" id=\"PresenceIcon"
                                            , sipAddress
                                            , "_"
                                            , Convert.ToString(guid)
                                            , "\" alt=\"presence icon for "
                                            , sipAddress
                                            , "\"/>"
                                            , "</span>"
                                            );
            }

Note: We need to generate a unique GUID for every user for the presence to work. 


Other Languages

This article is also available in the following languages:

Italian (it-IT)