A place for my programming projects and the occasional blog about technology related matters.
Who has deleted you from MSN?
Author einar
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 DotMSN 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 DotMSN;
// Author: Einar Egilsson
// http://tech.einaregilsson.com/2007/08/09/who-has-deleted-you-from-msn/
class MsnContactChecker
{
static Messenger msn = new Messenger();
static bool done = false;
static void Main(string[] args) {
string user, pass;
Console.Write("\\nMsnContactChecker v1.0\\n");
Console.Write("See ");
Console.Write("http://tech.einaregilsson.com/2007/08/09/who-has-deleted-you-from-msn/");
Console.Write(" for details\\n");
Console.Write("\\nUsername: ");
user = Console.ReadLine();
Console.Write("Password: ");
pass = Console.ReadLine();
Console.Write("\\nConnecting to MSN...");
try {
msn.SynchronizationCompleted +=
new Messenger.SynchronizationCompletedHandler(OnSynchronizationCompleted);
msn.Connect(user.Trim(), pass.Trim());
Console.WriteLine("done");
Console.Write("Getting contact list...");
msn.SynchronizeList();
} catch (Exception ex) {
Console.WriteLine("Error: " + ex.Message);
Console.WriteLine("\\nPress any key to quit program.");
Console.Read();
}
while (!done) {
System.Threading.Thread.Sleep(1000);
}
}
static void OnSynchronizationCompleted(Messenger msn, EventArgs e)
{
Console.WriteLine("done");
Console.WriteLine("\\nContacts that don't have you in their list:\\n");
int counter = 0;
foreach (Contact c in msn.ForwardList) {
if (!c.OnReverseList && c.Mail == c.Name) {
counter++;
Console.WriteLine(c.Mail);
} else if (!c.OnReverseList) {
counter++;
Console.WriteLine("{0} ({1})", c.Name, c.Mail);
}
}
if (counter == 0) {
Console.WriteLine("All your contacts have you on their lists.");
}
msn.CloseConnection();
Console.WriteLine("\\nPress any key to quit program.");
Console.Read();
done = true;
}
}
This should compile both on .NET 1.1 and 2.0. You can download the source and play with it. The zip file includes the MsnContactChecker.cs file and the library, DotMSN.dll. It’s an old version of the library, since that’s the one I had lying around, but if you want to do something more with this then you should probably upgrade to the latest version. To compile this you can write:
csc.exe MsnContactChecker.cs /r:DotMSN.dll
The compiler, csc.exe, is typically stored at c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 or c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 . Or just create a Visual Studio project if you have that.
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 ![]()
Reader's Comments
Comment
Options
-
August 9, 2007 -
C#, code, msn -
3 comments
-
Comments RSS -
Del.ico.us
-
Digg!
Categories
- ASP.NET (1)
- C# (4)
- code (10)
- extensions (2)
- haloscan (1)
- javascript (2)
- meta (2)
- mozilla (2)
- msn (1)
- plugins (2)
- python (3)
- tips & tricks (3)
- utilities (1)
- Visual Studio (1)
- wordpress (5)
- zenphoto (2)
thanx…works like a charm!!
Who blocked me on msn?
kak to? ja to niš ne kužim…..