<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Einar Egilsson &#187; MSN</title>
	<atom:link href="http://einaregilsson.com/category/msn/feed/" rel="self" type="application/rss+xml" />
	<link>http://einaregilsson.com</link>
	<description>A site for my programming pet projects</description>
	<lastBuildDate>Fri, 03 Feb 2012 20:08:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Who has deleted you from MSN?</title>
		<link>http://einaregilsson.com/who-has-deleted-you-from-msn/</link>
		<comments>http://einaregilsson.com/who-has-deleted-you-from-msn/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 00:00:30 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[MSN]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/09/who-has-deleted-you-from-msn/</guid>
		<description><![CDATA[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&#8217;t have you in their contact lists, either because they&#8217;d never [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Updated 05.09.2007: Minor changes to work with the new MSN protocol</strong></p>
<p>My wife showed me a website the other day where you could type in your email address and password for <del>MSN</del> Windows Live! Messenger, and it would show you which of your contacts didn&#8217;t have you in their contact lists, either because they&#8217;d never added you, or because they&#8217;d deleted you at some point. It&#8217;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&#8217;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&#8217;t want. So, since I already have a <a href="/projects/windows-live-bot/" title="Windows Live Bot">project that uses the MSN protocol</a> I figured I could probably whip something up myself. <span id="more-46"></span></p>
<p>(For those that have no interest in the programming and just want to have the program, you can <a href="/download/MsnContactChecker.exe"><strong>download it here</strong></a>, those interested in the implementation can keep reading). To connect to MSN I use the excellent <a href="http://code.google.com/p/msnp-sharp/">MSNPSharp</a> 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&#8217;t have you in theirs. Now, I wrote this program in about 20 minutes, so it&#8217;s not the most beautiful code in the world, and the error-handling is almost non-existant, but it works (for me at least <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ), I found 4 contacts that didn&#8217;t have me in their list and promptly deleted them. Here it is:</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Threading;
using MSNPSharp;

// Author: Einar Egilsson
// http://einaregilsson.com/2007/08/09/who-has-deleted-you-from-msn/
class MsnContactChecker
{
    readonly Messenger msn = new Messenger();
    const string Url =
        &quot;http://einaregilsson.com/2007/08/09/who-has-deleted-you-from-msn/&quot;;

    static void Main()
    {
        new MsnContactChecker().Check();
    }

    public void Check()
    {
        Console.WriteLine(&quot;\nMsnContactChecker v1.0\n{0}&quot;, Url);
        try
        {
            Console.Write(&quot;\nUsername: &quot;);
            msn.Credentials.Account = Console.ReadLine().Trim();
            Console.Write(&quot;Password: &quot;);
            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(&quot;\nConnecting to MSN...(this might take a little while)&quot;);
            msn.Connect();
            Thread.Sleep(Timeout.Infinite);
        }
        catch (Exception ex)
        {
            Error(this, new ExceptionEventArgs(ex));
        }
    }

    void Synchronized(object sender, EventArgs e)
    {
        Console.WriteLine(&quot;\nContacts that have deleted you:&quot;);
        int count = 0;
        foreach (Contact c in msn.ContactList.Forward)
        {
            if (!c.OnReverseList)
            {
                count++;
                if (c.Mail == c.Name)
                {
                    Console.WriteLine(&quot; {0}&quot;, c.Name);
                }
                else
                {
                    Console.WriteLine(&quot; {0} ({1})&quot;, c.Name, c.Mail);
                }
            }
        }
        if (count == 0)
        {
            Console.WriteLine(&quot; None of your contacts have deleted you&quot;);
        }
        Exit(0);
    }

    private void MsnError(object sender, MSNErrorEventArgs e)
    {
        Console.WriteLine(&quot;\nError: {0}&quot;, e.MSNError);
        Exit(1);
    }

    void Error(object sender, ExceptionEventArgs e)
    {
        Console.WriteLine(&quot;\nError: {0}&quot;, e.Exception.Message);
        Exit(1);
    }

    private void Exit(int code)
    {
        Console.WriteLine(&quot;\nPress any key to quit program&quot;);
        Console.Read();
        Environment.Exit(code);
    }
}
</pre>
<p>You can <a href="/download/MsnContactChecker.zip"><strong>download the source</strong></a> and play with it. The zip file includes the MsnContactChecker.cs file and the library, MSNPSharp.dll.</p>
<p>Or to just get the compiled program you can <a href="/download/MsnContactChecker.exe"><strong>download it here</strong></a>. It&#8217;s just a single executable file, since I used the excellent <a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx">ILMerge tool</a> from Microsoft to merge my .exe file and the DotMSN library into one file. Enjoy <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/who-has-deleted-you-from-msn/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

