Einar Egilsson

Who has deleted you from MSN?

Posted: Last updated:

UPDATED 01.05.2012: I have no idea whether this works with the latest version of Windows Live Messenger.

Updated 05.09.2007: Minor changes to work with the new MSN protocol.

My wife showed me a website the other day where you could type in your email address and password for MSN Windows Live! Messenger, and it would show you which of your contacts didn't have you in their contact lists, either because they'd never added you, or because they'd deleted you at some point. It's a cool idea and a good way to prune some of the contacts that you never speak to from your contact list. But I don't really wanna give up my user / pass to some third-party site, even though they promise not to log it anywhere, and most of these sites (at least the ones I saw) tried to make some money by sending advertisements to your contacts while they were checking them, which I definitely didn't want. So, since I already have a project that uses the MSN protocol I figured I could probably whip something up myself.

(For those that have no interest in the programming and just want to have the program, you can download it here, those interested in the implementation can keep reading). To connect to MSN I use the excellent MSNPSharp library. That takes care of all the hard stuff so all I have to do is connect, loop through the contacts and print out those that are in your contact list but don't have you in theirs. Now, I wrote this program in about 20 minutes, so it's not the most beautiful code in the world, and the error-handling is almost non-existant, but it works (for me at least :) ), I found 4 contacts that didn't have me in their list and promptly deleted them. Here it is:

using System; using System.Threading; using MSNPSharp; // Author: Einar Egilsson // http://einaregilsson.com/who-has-deleted-you-from-msn/ class MsnContactChecker { readonly Messenger msn = new Messenger(); const string Url = "http://einaregilsson.com/who-has-deleted-you-from-msn/"; static void Main() { new MsnContactChecker().Check(); } public void Check() { Console.WriteLine("\nMsnContactChecker v1.0\n{0}", Url); try { Console.Write("\nUsername: "); msn.Credentials.Account = Console.ReadLine().Trim(); Console.Write("Password: "); msn.Credentials.Password = Console.ReadLine().Trim(); msn.NameserverProcessor.ConnectingException += Error; msn.Nameserver.ExceptionOccurred += Error; msn.Nameserver.AuthenticationError += Error; msn.Nameserver.ServerErrorReceived += MsnError; msn.ContactService.SynchronizationCompleted += Synchronized; Console.WriteLine("\nConnecting to MSN...(this might take a little while)"); msn.Connect(); Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { Error(this, new ExceptionEventArgs(ex)); } } void Synchronized(object sender, EventArgs e) { Console.WriteLine("\nContacts that have deleted you:"); int count = 0; foreach (Contact c in msn.ContactList.Forward) { if (!c.OnReverseList) { count++; if (c.Mail == c.Name) { Console.WriteLine(" {0}", c.Name); } else { Console.WriteLine(" {0} ({1})", c.Name, c.Mail); } } } if (count == 0) { Console.WriteLine(" None of your contacts have deleted you"); } Exit(0); } private void MsnError(object sender, MSNErrorEventArgs e) { Console.WriteLine("\nError: {0}", e.MSNError); Exit(1); } void Error(object sender, ExceptionEventArgs e) { Console.WriteLine("\nError: {0}", e.Exception.Message); Exit(1); } private void Exit(int code) { Console.WriteLine("\nPress any key to quit program"); Console.Read(); Environment.Exit(code); } }

You can download the source and play with it. The zip file includes the MsnContactChecker.cs file and the library, MSNPSharp.dll.

Or to just get the compiled program you can download it here. It's just a single executable file, since I used the excellent ILMerge tool from Microsoft to merge my .exe file and the DotMSN library into one file. Enjoy :)

If you read this far you should probably follow me on Twitter.