Suddenly I thought I was a MSN robot, I found a .NET written library in Dotmsn. The call is very simple.
// Log in Private Void StartMSN () {if ((txtemail.text! = ") || (txtpsw.text! =")) {Msn.connect (txtemail.text, txtpsw.text); if (MSN. Connected) {// setup callback function msn.ContactOnline = new DotMSN.Messenger.ContactOnlineHandler (msn_ContactOnline); msn.ContactOffline = new DotMSN.Messenger.ContactOfflineHandler (OnContactOffline); msn.SynchronizationCompleted = new DotMSN.Messenger.SynchronizationCompletedHandler ( OnsynchronizationCompleted);
Msn.MessageReceived = new dotmsn.Messenger.MessageReceivedHandler (OnMessageReceive);
Msn.conversationCreated = new dotmsn.Messenger.conversationCreated;
Msn.synchronizelist (); txtlog.text = "msn connection / r / n" txtLog.Text;}}}
// Logout Private Void EndMSN () {if (msn.connected) {msn.closeConnection (); if (! Msn.connected) {txtlog.text = "msn disconnected / r / n" txtlog.text;}}}}}}
// Successfully Synchronize Contact List Private Void OnsynchronizationCompleted (Mssenger Sender, Eventargs E) {msn.setstatus (msnstatus.online); txtlog.text = "set status: online / r / n" txtLog.Text;
FillListView (lstViewFL, msn.GetListEnumerator (MSNList.ForwardList)); FillListView (lstViewRL, msn.ReverseList); FillListView (lstViewBL, msn.BlockedList); FillListView (lstViewAL, msn.AllowedList);}
/ / Contact launch private void msn_contactonline (Messenger sender, contactArgs e) {txtLog.text = E.Contact.Name "status:" E.Contact.status.toString () "/ r / n" txtlog. Text; RefreshListView (lstViewFL, e.Contact); RefreshListView (lstViewRL, e.Contact); RefreshListView (lstViewBL, e.Contact); RefreshListView (lstViewAL, e.Contact);} // offline contacts private void OnContactOffline (Messenger Sender, ContactEventArgs e) {txtLog.text = E.Contact.name "status:" E.Contact.status.tostring () "/ r / n" txtLog.Text; RefreshlistView (LstviewFL, E.Contact) RefreshlistView (LstviewRl, E.Contact); RefreshlistView (LstviewBL, E.Contact); RefreshlistView (Lstviewal, E.Contact);}
// initialize contact list private void FillListView (ListView lst, Messenger.ContactList.ListEnumerator contactList) {lst.Clear (); foreach (Contact contact in contactList) {ListViewItem item = new ListViewItem (contact.Name "status:" Contact.status.toString ()); item.tag = contact; lst.items.add (item);}}
// refresh the contact list private void RefreshListView (ListView lst, Contact contact) {foreach (ListViewItem item in lst.Items) {Contact itemtag = (Contact) item.Tag; if (itemtag.Mail.Equals (contact.Mail)) {Item.text = contact.name "status:" contact.status.tostring (); return;}} // listviewItem new listViewItem (Contact.Name "status:" contact.status.tostring () ); // newItem.tag = contact; // lst.items.add (newItem);
// Add conversation private void OnConversationCreated (Messenger sender, ConversationEventArgs e) {txtLog.Text = "ConversationCreated / r / n" txtLog.Text; e.Conversation.ContactJoin = new DotMSN.Conversation.ContactJoinHandler (ContactJoin); e. Conversation.MessageReceived = new DotMSN.Conversation.MessageReceivedHandler (MessageReceived); e.Conversation.UserTyping = new DotMSN.Conversation.UserTypingHandler (UserTyping);} #region display contacts Email private void lstViewFL_SelectedIndexChanged (object sender, System title bar . Eventargs e) {Displaymail ((listview) sender;}
Private void LstviewRl_selectedIndexchanged (Object Sender, System.EventArgs E) {Displaymail ((ListView) Sender;}
Private void Lstviewal_Selected IndexChanged (Object Sender, System.EventArgs E) {Displaymail ((ListView) Sender);}
private void lstViewBL_SelectedIndexChanged (object sender, System.EventArgs e) {DisplayMail ((ListView) sender);} private void DisplayMail (ListView lst) {if (lst.SelectedItems.Count == 1) {Contact contact = (Contact) lst. SelectedItems [0] .tag; this.text = contact.mail;}}
#ndregion
// Add Dialog Private Void ContactJoin (Conversation Sender, ContactEventArgs E) {txtLog.text = E.Contact.name " E.Contact.mail " "ContactJoin / R / N" txtLog.Text;}
// Receive Message Private Void MessageReceived (Conversation Sender, MessageEventArgs E) {txtlog.text = E.SENDER.NAME " E.SENDER.MAIL " E.MESSAGE.TEXT "/ R / N" txtlog.text; sender.sendMessage (E.MESSAGE.TEXT);
// TOEE Enter Private Void Usertyping (Conversation Sender, ContactEventAntargs E) {txtLog.text = E.Contact.name " E.Contact.mail " "IS type / r / n" txtLog.Text; } This is a complete project of some of the code. You can click here to download. This robot is now only a parrot, but you can make him very smart as long as you modify MessageReceiD. Even people in the list teach it to answer questions. As long as you have ideas.