Using the Messenger API in HTML

Published Thursday, October 13, 2005 6:44 PM
I was curious if this was possible. A lot of people want to be able to show presence information in web pages, but don't want to have deploy lots of server controls.

Here is an example showing how to show a count of unread email in your inbox:

<object id="objMessenger" classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" VIEWASTEXT></object>
<script language="jscript">
function updateUnreadEmail()
{
 spanUnreadEmail.innerHTML=objMessenger.UnreadEmailCount(0);
}
</script>
<span id="spanUnreadEmail"></span>
You'll then need to invoke the updateUnreadEmail() function which you could do in the body's onload event.  This is all client side and can be in any web page.  There is no error handling so it only works if you have Messenger running and signed in, but what this shows is what I wanted to find out which is that it is possible.

This information is not in the MSN Messenger developer center.  The way I found it was to download the Office Communicator Presence Controls.  They install a Messenger APIs help file (CHM file).  There they list all of the methods, properties, events, and, the secret codes, the class IDs.
Filed under: ,

Comments

# Jason Mauss said on Thursday, October 13, 2005 8:24 PM

Very interesting....thanks for sharing.

# shiv said on Thursday, October 13, 2005 10:52 PM

hello westin,

i tried the above code in my website and i keep getting the following error:
'objMessenger' is undefined...any ideas what i could be doign wrong?

thx,
shiv

# Westin said on Thursday, October 13, 2005 10:57 PM

Well, make sure all of the following are true:
1) You have MSN Messenger installed and running (probably better to have the latest version, 7.5, from http://messenger.msn.com)
2) Make sure you have installed the presence controls, the link is in the article. I'm not sure if that is required, but it's on my machine. I suppose I could go searching through the registry for the class id to figure out exactly which it is pointing to, but...
3) Make sure that you have the object tag placed in your HTML document and that it is called 'objMessenger' and has the correct class id.

# Mark Kruger said on Friday, October 14, 2005 8:39 AM

Another sample of a script you can add to show your messenger presence which was extracted from SharePoint itself:

http://www.sharepointblogs.com/mkruger/archive/2005/08/12/3150.aspx

Leave a Comment

(required) 
(required) 
(optional)
(required)