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 

1) Userprofile property SipAddress or

2) Userprofile property WorkEmail or

3) 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.