{"id":115,"date":"2006-12-02T23:11:06","date_gmt":"2006-12-03T04:11:06","guid":{"rendered":"\/cgi\/wp\/?p=115"},"modified":"2006-12-02T23:11:06","modified_gmt":"2006-12-03T04:11:06","slug":"aspnet-and-msn-messenger","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=115","title":{"rendered":"ASP.NET and MSN Messenger"},"content":{"rendered":"<p>I have been working on a web application that can send me text messages using MSN Messenger. It works pretty well except I have to double click the contact to join the conversation before I can receive the message. I get an alert that my contact has come online but not that they have sent a message. My prototype is using the DotMSN 1.2 DLL which you can download at: <a href=\"http:\/\/www.xihsolutions.net\/dotmsn\/download\/version1\/DotMSN.dll \">http:\/\/www.xihsolutions.net\/dotmsn\/download\/version1\/DotMSN.dll<\/a>. Make sure you add a reference to that DLL in your Visual Studio 2003 project. You will need two MSN Messenger contact accounts to test this web application. I recommend using an alternative email address and MSN Messenger 4.7 with Windows Live Messenger on the same machine. Here is my working VB.NET code which took a long time to figure out. I could not find any complete sample code on the Internet:<\/p>\n<pre>\r\n<font color= \"blue\">Imports<\/font> DotMSN\r\n<font color= \"blue\">Public<\/font> <font color= \"blue\">Class<\/font> Message\r\n    <font color= \"blue\">Inherits<\/font> System.Web.UI.Page\r\n\r\n#Region &quot; Web Form Designer Generated Code &quot;\r\n\r\n    <font color= \"green\">'This call is required by the Web Form Designer.<\/font>\r\n    &lt;System.Diagnostics.DebuggerStepThrough()&gt; <font color= \"blue\">Private<\/font> <font color= \"blue\">Sub<\/font> InitializeComponent()\r\n\r\n    <font color= \"blue\">End Sub<\/font>\r\n\r\n    <font color= \"green\">'NOTE: The following placeholder declaration is required by the Web Form Designer.<\/font>\r\n    <font color= \"green\">'Do not delete or move it.<\/font>\r\n    <font color= \"blue\">Private<\/font> designerPlaceholderDeclaration <font color= \"blue\">As<\/font> System.Object\r\n\r\n    <font color= \"blue\">Private<\/font> <font color= \"blue\">Sub<\/font> Page_Init(ByVal sender <font color= \"blue\">As<\/font> System.Object, ByVal e <font color= \"blue\">As<\/font> System.EventArgs) Handles <font color= \"blue\">MyBase<\/font>.Init\r\n        <font color= \"green\">'CODEGEN: This method call is required by the Web Form Designer<\/font>\r\n        <font color= \"green\">'Do not modify it using the code editor.<\/font>\r\n        InitializeComponent()\r\n    <font color= \"blue\">End Sub<\/font>\r\n\r\n#End Region\r\n\r\n    <font color= \"blue\">Protected<\/font> WithEvents btnContact <font color= \"blue\">As<\/font> System.Web.UI.WebControls.Button\r\n\r\n    <font color= \"blue\">Private<\/font> <font color= \"blue\">Sub<\/font> Page_Load(ByVal sender <font color= \"blue\">As<\/font> System.Object, ByVal e <font color= \"blue\">As<\/font> System.EventArgs) Handles <font color= \"blue\">MyBase<\/font>.Load\r\n        <font color= \"green\">'Put user code to initialize the page here<\/font>\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Public<\/font> <font color= \"blue\">Sub<\/font> ConversationCreated(ByVal sender <font color= \"blue\">As<\/font> Messenger, ByVal e <font color= \"blue\">As<\/font> ConversationEventArgs)\r\n        AddHandler e.Conversation.ContactJoin, AddressOf ContactJoined\r\n        AddHandler e.Conversation.ConnectionEstablished, AddressOf ConnectionEstablished\r\n        AddHandler e.Conversation.UserTyping, AddressOf UserTyping\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Public<\/font> <font color= \"blue\">Sub<\/font> ConnectionEstablished(ByVal sender <font color= \"blue\">As<\/font> Conversation, ByVal e <font color= \"blue\">As<\/font> EventArgs)\r\n        <font color= \"green\">' do nothing<\/font>\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Public<\/font> <font color= \"blue\">Sub<\/font> UserTyping(ByVal sender <font color= \"blue\">As<\/font> Conversation, ByVal e <font color= \"blue\">As<\/font> ContactEventArgs)\r\n        <font color= \"green\">' do nothing<\/font>\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Public<\/font> <font color= \"blue\">Sub<\/font> ContactOnline(ByVal sender <font color= \"blue\">As<\/font> Messenger, ByVal e <font color= \"blue\">As<\/font> ContactEventArgs)\r\n        <font color= \"green\">' do nothing<\/font>\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Public<\/font> <font color= \"blue\">Sub<\/font> OnSynchronizationCompleted(ByVal sender <font color= \"blue\">As<\/font> Messenger, ByVal e <font color= \"blue\">As<\/font> EventArgs)\r\n        sender.SetStatus(MSNStatus.Online)\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Private<\/font> <font color= \"blue\">Sub<\/font> ContactJoined(ByVal sender <font color= \"blue\">As<\/font> Conversation, ByVal e <font color= \"blue\">As<\/font> ContactEventArgs)\r\n        <font color= \"green\">' the contact must clicked on to receive this message<\/font>\r\n        sender.SendMessage(&quot;:D Hi! &quot; &amp; Now())\r\n    <font color= \"blue\">End Sub<\/font>\r\n    <font color= \"blue\">Private<\/font> <font color= \"blue\">Sub<\/font> btnContact_Click(ByVal sender <font color= \"blue\">As<\/font> Object, ByVal e <font color= \"blue\">As<\/font> System.EventArgs) Handles btnContact.Click\r\n        <font color= \"blue\">Dim<\/font> MSN <font color= \"blue\">As<\/font> Messenger\r\n        MSN = <font color= \"blue\">New<\/font> Messenger\r\n\r\n        AddHandler MSN.ContactOnline, AddressOf ContactOnline\r\n        AddHandler MSN.ConversationCreated, AddressOf ConversationCreated\r\n        AddHandler MSN.SynchronizationCompleted, AddressOf OnSynchronizationCompleted\r\n\r\n        <font color= \"green\">' this account will be signed out<\/font>\r\n        MSN.Connect(&quot;robert@williamsportwebdeveloper.com&quot;, &quot;*******&quot;)\r\n        MSN.SynchronizeList()\r\n\r\n        <font color= \"green\">' account to contact with message<\/font>\r\n        MSN.RequestConversation(&quot;robert_robbins@verizon.net&quot;)\r\n    <font color= \"blue\">End Sub<\/font>\r\n<font color= \"blue\">End Class<\/font><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/www.williamsportwebdeveloper.com\/images\/blog\/MSN-Messenger.jpg\" alt=\"Example of a conversation\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been working on a web application that can send me text messages using MSN Messenger. It works pretty well except I have to double click the contact to join the conversation before I can receive the message. I &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=115\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/115"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":0,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}