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: http://www.xihsolutions.net/dotmsn/download/version1/DotMSN.dll. 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:
Imports DotMSN Public Class Message Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Protected WithEvents btnContact As System.Web.UI.WebControls.Button Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Public Sub ConversationCreated(ByVal sender As Messenger, ByVal e As ConversationEventArgs) AddHandler e.Conversation.ContactJoin, AddressOf ContactJoined AddHandler e.Conversation.ConnectionEstablished, AddressOf ConnectionEstablished AddHandler e.Conversation.UserTyping, AddressOf UserTyping End Sub Public Sub ConnectionEstablished(ByVal sender As Conversation, ByVal e As EventArgs) ' do nothing End Sub Public Sub UserTyping(ByVal sender As Conversation, ByVal e As ContactEventArgs) ' do nothing End Sub Public Sub ContactOnline(ByVal sender As Messenger, ByVal e As ContactEventArgs) ' do nothing End Sub Public Sub OnSynchronizationCompleted(ByVal sender As Messenger, ByVal e As EventArgs) sender.SetStatus(MSNStatus.Online) End Sub Private Sub ContactJoined(ByVal sender As Conversation, ByVal e As ContactEventArgs) ' the contact must clicked on to receive this message sender.SendMessage(":D Hi! " & Now()) End Sub Private Sub btnContact_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnContact.Click Dim MSN As Messenger MSN = New Messenger AddHandler MSN.ContactOnline, AddressOf ContactOnline AddHandler MSN.ConversationCreated, AddressOf ConversationCreated AddHandler MSN.SynchronizationCompleted, AddressOf OnSynchronizationCompleted ' this account will be signed out MSN.Connect("robert@williamsportwebdeveloper.com", "*******") MSN.SynchronizeList() ' account to contact with message MSN.RequestConversation("robert_robbins@verizon.net") End Sub End Class