65.9K
CodeProject is changing. Read more.
Home

Set Your MSN Live Messenger to Auto Reply

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.87/5 (8 votes)

Jan 27, 2007

3 min read

viewsIcon

67566

downloadIcon

389

What if one is getting angry when sending you IMs but not getting any Response. If he/she got patience , then you are safe. But there could be a punch for you on next DATE. Why spoil your DATE. Just go on installing this "AutoReplyAddIn".

Introduction

Customizing MSN Live Messenger to fullfill one's requirement is a great idea. Micosoft offer great Add-In feature to write the Add-Ins for your MSN Live Messenger. Writing an Add-in with Dot.Net Framework 2.0 is just a piece of Cake. So why dont try eating it. Tell me after eating that it was delicious.....ammm..

There are three steps to consider for watching your Add-In working.

  1. Enabling Live Messenger to accept Add-Ins
  2. Writing your Add-In
  3. Registering Add-In with Messenger

Enabling Live Messenger to Accept Add-Ins

hey dont worry, this is also an easy step.

Just follow the instructions

Run your Registry Editor

Start--> Run--> Regedit

Scroll to following Registry KeyHKEY_CURRENT_USER\Software\Microsoft\MSNMessenger

create a new DWORD entry AddInFeatureEnabled, if it is not there. then set its value to 1.

Now restart your Messenger

Writing Add-In

Create a new C# or whatever .Net language you like.

File--> New--> Project-->Class Library

Now Add Reference to MessengerClient.dll

Right Click on your Solution Name-->Add Refrence

Browse for MessengerClient.dll (most probably at C:\Program Files\MSN Messenger )

Now to avoid fully qualified names of types that we are going to use , you should add

using

The next step is to go on writing a class named AddIn(You can choose whatever name you like). But mind one thing that this class should me implementing an Interface

{

User userFrom = e.UserFrom;

Client.SendNudgeMessage(userFrom);

Client.SendTextMessage(

}

"Hey, I m busy. Please leave your message ", userFrom);

Now just build or compile your solution. This will create a dll called your_namespace_name.dll in bin folder of your application. Just browse to that folder and rename that dll. to

your_namespace_name.yourClassName.dll

Now your done with all the Code effort.

Registering your Add-In to Live Messenger

Open up your Live Messenger

Tools--> Options, Your will have an Add-In option click it and browse to your dll created in above steps.

Run Messenger and get your Add-In working.

NOTE: This Article just gives an idea about working with Add-Ins for Windows Live Messenger. A thorough understanding of of Windows Live Messenger Add-In API can be found at http://msdn2.microsoft.com/en-us/library/aa905655.aspx

Here is the complete listing of Code

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Messenger;


namespace

AutoReplyAddIn
{public class AddIn:IMessengerAddIn
{private MessengerClient client = null;public void Initialize(MessengerClient messenger)
{ // Initialize your Add-in hereClient = messenger;// Set Add-in properties here//////////////////////////////////////////////////Client.AddInProperties.Creator = "Shehzad Ahmed"; Client.AddInProperties.Description = "An Add-in to send Auto Replies"; Client.AddInProperties.FriendlyName = "Auto Reply Add-In"; Client.AddInProperties.PersonalStatusMessage = "Auto Reply Add-in Activated";Client.AddInProperties.Status = UserStatus.Online; // Register Handler for Incoming Text MessagesClient.IncomingTextMessage+=new ventHandler<IncomingTextMessageEventArgs> (Client_IncomingTextMessage);
}public void Client_IncomingTextMessage(Object Sender, IncomingTextMessageEventArgs e)
{User userFrom = e.UserFrom;Client.SendNudgeMessage(userFrom);
Client.SendTextMessage("Hey, I m busy. Please leave your message ", userFrom);
}public MessengerClient Client
{get{ return client; }private set{
client = value;
}
}
}
}

IMessengerAddIn

public class AddIn:IMessengerAddIn

IMessengerAddIn offers Initialize Method that must be implemented.

public

Since we are aiming to send only an Auto Reply, we just need register with the

IncomingTextMessage event as new EventHandler<IncomingTextMessageEventArgs>(Client_IncomingTextMessage);

Client.IncomingTextMessage+=

Now just go on writing Event Handler

public

void Client_IncomingTextMessage(Object Sender, IncomingTextMessageEventArgs e) void Initialize(MessengerClient messenger){} Microsoft.Messenger