Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Discover the top 5 tips for understanding .NET Interop
Search :       Advanced Search »
Home » Internet & Web » Enhanced MSN Messenger in C# using Windows Forms

Enhanced MSN Messenger in C# using Windows Forms

This application will provide certain useful features which are not present in Microsoft MSN Messenger.

Author Rank :
Page Views : 57412
Downloads : 2731
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
MSNMessengerController.zip
 
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Introduction:

 

We are using MSN Messenger for past so many years. It has been improved a lot in terms of functionality and UI from its first release up to now. But, it is still missing some functionality which might be useful in certain situations. So, I designed this application which will provide certain features which are not available in MSN Messenger. I designed this application in VS.NET 2003 using C# and Windows Forms. I will explain little bit about the application than I will explain design and coding of this application.

 

Features present in this Application:

  • Allows to see contact list and message history.
  • Allows to browse message history sorted by date.
  • Allows to mail  message history of selected user.
  • Allows to Monitor any contact status.
  • Automatically reloads contact's status, when the status changes.
  • Maintains a list of recent users, to whom you messaged. 

Steps to create this application:

 

First, create a new windows project in C# and add a COM dll named Interop.MessengerAPI.dll to project's references. This dll is present in code folder in the attachment or you can search for it in Google. Than design the main form as shown below:

 

Here, I am using a ListView control to display all contacts. Than, I designed MainMenu for following functionality, to sort users based on their status, to  notify any status changes of selected contact, to view message history of a contact sorted by date, to mail selected user's message history, to maintain recent user's list to whom you messaged, automatic update of listview whenever a user changes status, to exit from application. After creating Main form, add new forms and name it each as historywindow, alerts, MessageViewer. Design this forms as shown below:

 

History Window:

 

 

Alters Window:

 

 

MessageViewer Window:

 

 

Now, I will explain important steps in coding each form.

 

Main form (Form1.cs):


In form load, I am creating an instance of msn messenger. Later, I am getting path of message history, which will be stored in registry. This registry entry will be different for each computer. You can get path of message history by searching registry with this key MessageLogPath. Later, copy this key path and paste in app.config in value field of key registryPath. Normally, MSN messenger will store each user history in the path stored in MessageLogPath registry entry in the form of xml file with a default xsl file to format it.

 

Later, I am adding a method to be invoked wherever a user changes his status to update ListView Control with updated status of all users. Finally, I am looping through each contact of Messenger and adding it to ListView with some hidden columns with proper Color.

 

In ShowUserswho menuitem will sort users based on their status. Here also I am just looping through each contact and adding them to ListView based on their status.

 

ViewSelectedUserHistory menuitem will show selected user's history in a new window.


Upload History menuitem will allows us first to select users whose history to be mailed and later it will mail selected user's history to mail id you specified in the textbox. By using this we can view our message history from any system.

 

Recentusers menuitem will maintain list of users to whom you messaged recently.

 

HistoryWindow:

 

In Form1, we are copying the message history of selected user into a string variable mesghistorydetails and displaying it in historywindow textbox. I am using this code to get selected user's history:

 

IMessengerContact selectedcontact = msn.GetContact(listView1.SelectedItems[0].SubItems[1].Text,listView1.SelectedItems[0].SubItems[3].Text) as IMessengerContact;

IMessengerConversationWnd cw  = msn.InstantMessage(selectedcontact) as IMessengerConversationWnd;

if(cw.History.ToString()!="")

{

    string mesghistory=cw.History.ToString();

    mesghistory= mesghistory.Replace(msn.MyFriendlyName,"You ");

    mesghistory= mesghistory.Replace(selectedcontact.FriendlyName,"He/She ");

    IMessengerWindow window=cw as IMessengerWindow ;

    mesghistoryContactName =selectedcontact.FriendlyName;

    window.Close();

    mesghistorydetails=mesghistory;

    HistoryWindow objform2 = new HistoryWindow();

    objform2.Show();

}

 

Here, I am getting selected user's signname and serviceid from ListView control, later getting his/her history using IMessengerConversationWnd object.

 

Alerts Window:

 

Here, I am getting all contact's friendly name and adding it to a combobox. I am adding method to be invoked whenever a contact changes his/her status. In this method, I am adding his previous and current status to listbox. By using this, we can know the exact time of status change of any contact. Normally, I will use this to keep track status of my Lead. Whenever his status changes to AWAY, I will start working more sincerely.

 

MessageViewer Window:

 

Normally message history of any contact will be stored in local hard disk in path specified in MessageLogPath registry key in the form of xml file. Here, we have to browse selected user's message history file using filedialog control. Later, we can view message history based on its date with respect to current date.

 

Final Output will be like this:

 

 

 

 

 

We can still enhance this Messenger by adding little bit of code. I hope this code will be useful for all. I am attaching code for further reference.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Sateesh Arveti
I hold Bachelors degree in Computer Science along with MCSD,MCTS and MVP for the year 2009. Areas of Interest: C#, WPF, WF, silverlight, ASP.NET, Oracle and SQL Server.

Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
How to send instant message to a conatct in C# by sathis On April 6, 2007
hi, i am sathis kumar i need to send a insatnt message to a conatct from a c# code. i had populted the all contacts ina window. need to send a txt message when user select any contact from the list pls help me out thanks in advance
Reply | Email | Modify 
Re: How to send instant message to a conatct in C# by Sateesh On April 6, 2007
hi satish, Use this code to send instant mesg ... [DllImport("user32")] public static extern bool SetForegroundWindow(IntPtr hwnd); void SendMessage(string text) { IMessengerContact mc = msn.GetContact(listView1.SelectedItems[0].SubItems[1].Text,listView1.SelectedItems[0].SubItems[3].Text) as IMessengerContact; IMessengerConversationWnd _mcw = msn.InstantMessage(mc) as IMessengerConversationWnd; if (SetForegroundWindow((IntPtr)_mcw.HWND)) { SendKeys.SendWait(text); SendKeys.SendWait("{ENTER}"); } IMessengerWindow window=_mcw as IMessengerWindow ; window.Close(); }
Reply | Email | Modify 
problems executing on another machine by nigel On April 14, 2007
Hi sateesh, great piece of code. I downloaded and compiled and it works great, but when i copy the debug directory to another pc and try and run it from there it errors , i also created a setup package and it still fails with the same error> Unhandled Exception when it executes this line msn = new MessengerAPI.MessengerClass(); Interop.MessengerAPI.dll is present, its an XP machine Any ideas, Thanks :-)
Reply | Email | Modify 
Receive Inastant Messages by zainee On June 26, 2007
Hi! Its a great article and it helped me a lot. Thanks a lot for shring your work. I have one question... You answered above for sending an instant message, its working absolutely fine when i included that piece of code in my application which is doing the conversation in the windows forms, not in the original messanger window. I am sending the messages successfully, can you please let me know the method for getting the instant messages -i.e retriving the replied instant messages? Like conversation in windows forms rather the MSN conversation window. I would be highly thankful to you if you help me in this regard. Thanks in advance! Regards ZA
Reply | Email | Modify 
code by ahmsimsek On July 22, 2007
I cannot see the code attachment, did you remove it ?
Reply | Email | Modify 
Problems in running the MSNMessengerController by Rui On January 3, 2008
I tried to run the MSNMessengerController I got this error Retrieving the COM class factory for component with CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} failed due to the following error: 80040154." on the line msn = new MessengerAPI.MessengerClass(); Can you help me? Thank you very much
Reply | Email | Modify 
Problems in running the MSNMessengerController by Rui On January 3, 2008

I tried to run the MSNMessengerController I got this error Retrieving the COM class factory for component with CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} failed due to the following error: 80040154." on the line msn = new MessengerAPI.MessengerClass(); ´

The computer where I' m running has the windows server 2003 and does not have any messenger installed

Can anyone help me? Thank you very much

Reply | Email | Modify 
Re: Problems in running the MSNMessengerController by Sateesh On January 8, 2008
Hi, This application runs on top of MSN or Windows Messenger.So,it is required to install them.
Reply | Email | Modify 
Re: Re: Problems in running the MSNMessengerController by rajesh On January 8, 2008
How to send instant msg in web apllication.. plz help me
Reply | Email | Modify 
Re: Re: Problems in running the MSNMessengerController by Rui On January 8, 2008

Today I installed the Windows live messenger v8.1 and I still have the same error. I'm running in debug. 

I went to DCOM config and can´t find the CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28}.

Best regards,

Rui Lourenço

Reply | Email | Modify 
Re: Re: Re: Problems in running the MSNMessengerController by Sateesh On January 9, 2008
Hi, I think Windows Live Messenger is the higher version of MSN Messenger.So,It wont support it.Better try with old version of MSN Messenger...
Reply | Email | Modify 
Re: Re: Re: Re: Problems in running the MSNMessengerController by Rui On January 9, 2008

I removed the messenger v8.1 and installed the 7.5 and it still does not work. Still the same error. Do you recommend a specific version?

Keep in mind that the computer is running on windows server 2003

Best regards

Reply | Email | Modify 
HOW TRANSFER FILE?AS IN MSN by heba On February 14, 2008
IWANT APPEAR THAT GOING SENT ON THE FORM
Reply | Email | Modify 
HOW TRANSFER FILE?AS IN MSN by heba On February 14, 2008
IWANT APPEAR THAT GOING SENT ON THE FORM
Reply | Email | Modify 
But,How I to get MessageAPI reference?? by yuzheng On July 22, 2009
But,How I to get MessageAPI  reference??
Reply | Email | Modify 
DevExpress Free UI Controls
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.