If you want to put that cool feature available @ http://msnbc.msn.com (click here for an example) which you can share some content with any or all of your contacts in Messenger, read this!
They call it "launching an activity", the original documentation you can find here.
File "MSGRP2P.xml"
<?xml version="1.0"?>
<Entry>
<EntryID>7</EntryID>
<Error />
<Locale>pt-br</Locale>
<Kids>0</Kids>
<Page>1</Page>
<Category>50</Category>
<Sequence>10</Sequence>
<Name>Oh boy! On ASP.NET</Name>
<Description>Share content through MSN</Description>
<URL>http://your_machine_name_or_host/Application/ViewContent.aspx</URL>
<IconURL />
<PassportSiteID>0</PassportSiteID>
<Type>App</Type>
<Height>500</Height>
<Width>500</Width>
<Location>side</Location>
<MinUsers>2</MinUsers>
<MaxUsers>2</MaxUsers>
<PassportSiteID>0</PassportSiteID>
<EnableIP>False</EnableIP>
<ActiveX>False</ActiveX>
<SendFile>False</SendFile>
<SendIM>False</SendIM>
<ReceiveIM>False</ReceiveIM>
<ReplaceIM>False</ReplaceIM>
<Windows>False</Windows>
<MaxPacketRate>120</MaxPacketRate>
<UserProperties>False</UserProperties>
<ClientVersion></ClientVersion>
<AppType>0</AppType>
<Hidden>false</Hidden>
</Entry>
This is the configuration file of your activity. To actually share content in a production enviroment you need to register your activity in Windows Live Gallery. If you want the same feature as MSNBC web site, you should get the MSGRP2P.xml file above and just change the Locale, Name, Description and URL nodes. Detailed explanation of each node can be found at http://msdn2.microsoft.com/en-us/library/aa751073.aspx.
Just AFTER your Activity be approved by Microsoft you will receive a production Application ID and you may test it integrated with the browser, before that, you need to place this XML in the same directory MSN executable file is and send the SAME XML file to somebody else who is going to test the activity with you. Place the XML file in the same directory MSN executable is too.
File "Default.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MSN</title>
<script type="text/javascript" language="javascript">
function IMThis(contentID)
{
try
{
var obj = new ActiveXObject("MSNMessenger.P4QuickLaunch");
}
catch(e)
{
obj=null;
};
if(obj!=null)
{
SaveCookie('CONTENTID', contentID, 10);//cookie will expire in 10 days
//obj.LaunchApp('7', '');
}
else
{
alert('User does not have MSN installed or is using Firefox.');
}
}
function SaveCookie(name, value, expirationTime)
{
var expirationDate=new Date();
expirationDate.setDate(expirationDate.getDate()+expirationTime);
document.cookie = name + "=" + escape(value) + ((expirationTime==null) ? "" : "; expires="+expirationDate.toGMTString());
}
</script>
</head>
<body>
<form id="frmDefault" runat="server">
<h1>Contents</h1>
<h2>Some content 1</h2><a href="javascript: IMThis('1');" title="Send content 1 using MSN">Send by MSN</a>
<h2>Some content 2</h2><a href="javascript: IMThis('2');" title="Send content 2 using MSN">send by MSN</a>
<h2>Some content 3</h2><a href="javascript: IMThis('3');" title="Send content 3 using MSN">send by MSN</a>
</form>
</body>
</html>
We got a table of contents inside the form which simulates the contents people who visit your site is going to share with their contacts.
The "IMThis" function receives the content ID, try to launch MSN (Obviously won't work for who doesn't have MSN installed) and stores the content ID in a cookie through the SaveCookie function.
After you receive your production application ID from Microsoft, you may uncomment the line "obj.LaunchApp('7', '')" and replace '7', which is a test id with the application id you received from http://gallery.live.com.
File "ViewContent.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
HttpCookie contentID = Request.Cookies["CONTENTID"];
this.FindControl(String.Format("div{0}", contentID.Value.ToString())).Visible = true;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>View Shared Content</title>
</head>
<body>
<h1>Content</h1>
<div id="div1" visible="false" runat="server">
<h2>Content ID: 1</h2>
</div>
<div id="div2" visible="false" runat="server">
<h2>Content ID: 2</h2>
</div>
<div id="div3" visible="false" runat="server">
<h2>Content ID: 3</h2>
</div>
</body>
</html>
This file just read the cookie saved by "Default.aspx" and displays the right content accordingly to the content id stored in the cookie.
How to test it
Send the URL you placed the Default.aspx file (something like http://yourmachinename/msn/default.aspx) to the contact you send the XML file, asks him/her to click in a "Send by MSN" link. After that, open the "Actions" menu, search for "Start [Name node in MSGRP2P.xml]" and waits to your test partner accepts the invitation. If he/she accepts the invitation, the Activity windows will open in the left of your and his/her conversation window redirected to the URL you supplied in the URL node of the MSGRP2P.xml file. The URL you supplied must be the file which reads the cookie and displays the right content. Got the magic?
I know this example is dumb but that's the most simple way I found to show people how to do it, any doubts, suggestion or anything else contact me please ;)
Sorry for the bad english and too long explanation/post, but I choose to detail it to the lower level to make it easir to understand since there is little to none documentation on this topic around the Internet.
Attention: Firefox don't support ActiveX objects or ActiveX can't support Firefox, so this feature won't work on Firefox. Opera would, though.
I wrote this article to reply Bilal's question at MSDN Forums. I hope it helps you Bilal ;)
Soundtrack to this post: Ja Rule feat. R. Kelly - Wonderful - yes I'm soft today ;)