Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Networking » 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:
Technologies: .NET 1.0/1.1, Windows Forms, XML,Visual C# .NET
Total downloads : 1485
Total page views :  34975
Rating :
 5/5
This article has been rated :  2 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
MSNMessengerController.zip
 
ArticleAd
Become a Sponsor



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.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Sateesh Kumar
  I have over 4 years of IT industry experience with Microsoft technologies.I hold Bachelors degree in Computer Science along with MCSD,MCTS. Areas of Interest: 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.
Boost the performance of your .NET applications
“ANTS Profiler took us straight to the specific areas of our code which were the cause of our performance issues." Terry Phillips, Sr. Developer, Harley-Davidson Dealer Systems. Download your free trial of ANTS Profiler.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
MSNMessengerController.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
ArticleAd
Become a Sponsor
Latest Comments:
Subject Posted By Posted On
How to send instant message to a conatct in C#sathis4/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 | Delete | Modify | 
 
 
Re: How to send instant message to a conatct in C#Sateesh4/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 | Delete | Modify | 
problems executing on another machinenigel4/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 | Delete | Modify | 
Receive Inastant Messageszainee6/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 | Delete | Modify | 
codeahmsimsek7/22/2007
I cannot see the code attachment, did you remove it ?
Reply | Email | Delete | Modify | 
Problems in running the MSNMessengerControllerRui1/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 | Delete | Modify | 
Problems in running the MSNMessengerControllerRui1/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 | Delete | Modify | 
 
 
Re: Problems in running the MSNMessengerControllerSateesh1/8/2008
Hi, This application runs on top of MSN or Windows Messenger.So,it is required to install them.
Reply | Email | Delete | Modify | 
 
Re: Re: Problems in running the MSNMessengerControllerrajesh1/8/2008
How to send instant msg in web apllication.. plz help me
Reply | Email | Delete | Modify | 
 
Re: Re: Problems in running the MSNMessengerControllerRui1/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 | Delete | Modify | 
 
Re: Re: Re: Problems in running the MSNMessengerControllerSateesh1/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 | Delete | Modify | 
 
Re: Re: Re: Re: Problems in running the MSNMessengerControllerRui1/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 | Delete | Modify | 
HOW TRANSFER FILE?AS IN MSNheba2/14/2008
IWANT APPEAR THAT GOING SENT ON THE FORM
Reply | Email | Delete | Modify | 
HOW TRANSFER FILE?AS IN MSNheba2/14/2008
IWANT APPEAR THAT GOING SENT ON THE FORM
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved