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.