Recuperer les contacts msn : introduction msn api

Description

C'est un début d'utilisation du framework de MSN.
Il permet de recuperer vos contacts.
Je vous montre le chemin, a vous de poursuivre la route :)

Source / Exemple :


using System;

namespace MsnTools
{
	/// <summary>
	/// Description résumée de MSNUtils.
	/// </summary>
	public class MSNUtils
	{
		private Messenger.MsgrObjectClass oMsn;
		private System.Windows.Forms.ListControl lstToCtc;
		private System.Windows.Forms.Label lbl;
		public  System.Collections.ArrayList myContacts;

		public MSNUtils(System.Windows.Forms.ListControl forContact,System.Windows.Forms.Label lab)
		{
			this.lstToCtc = forContact;
			this.lbl = lab;
			oMsn = new Messenger.MsgrObjectClass();
			this.oMsn.OnLogonResult  += new Messenger.DMsgrObjectEvents_OnLogonResultEventHandler(this.logged);	
		}
		public void logIn(string strUser,string strPass)
		{
			oMsn.Logon(strUser,strPass,oMsn.Services.PrimaryService);	
		}
		public void logOut()
		{
			oMsn.Logoff();
		}
		private void logged(int obj, Messenger.IMsgrService service)
		{
			this.lbl.Text = "Loggué";
			fillLB();
		}
		public System.Collections.ArrayList getMyContacts()
		{
			System.Collections.ArrayList myContacts= new System.Collections.ArrayList();
			foreach (Messenger.IMsgrUser user in oMsn.get_List(Messenger.MLIST.MLIST_CONTACT))
				myContacts.Add(user);
			return myContacts;
		}

		public string getLogonName()
		{
			return null;
		}

		private void fillLB()
		{
			Messenger.IMsgrUser usr;
			myContacts = getMyContacts();
			int foo = 0;
			while(foo++ < myContacts.Count-1)
			{
				usr = (Messenger.IMsgrUser)myContacts[foo];
				((System.Windows.Forms.ListBox)lstToCtc).Items.Add(usr.FriendlyName + "(" + usr.State.ToString() + ")");
			}
		}

			
	}
}

Conclusion :


Bien entendu ce n'est pas utilisable tel quel , mais il apporte un début de solution à ceux qui désire explorer.

N'oubliez pas de changer l'user et le mot de passe.

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.