Thursday, August 23, 2012
How to import contacts from MSN Messenger using your Hotmail e-mail
Introduction
This guide will show users how to make a hotmail e-mail and download or import your contacts using ASP.NET programming.
This type of functionality is useful if you're building a Web 2.0 site, a social networking site or something that can benefit the users are able to easily import their contacts from MSN Messenger on your website. You can see this kind of functionality on many websites today including MySpace, Facebook and GroupBox. I said Groupbox why this is, of course, my site. GroupBox is a website for online groups and the function you are going to learn is that I implemented to make it easier for users to import their contacts from MSN Messenger.
After reading this guide you will be able to: Import contacts from MSN Messenger users using your e-mail MSN Hotmail and MSN password.
What you need: I need to assume you know a little 'programming on the web, the NET framework, and in this case some VB.NET ..
Much of the work for the import of contacts from MSN Messenger has been done for you by a group called XIH. They have a class library named library DotMSN Messaging. We will need this class library and then I put a link to my blog where you can download at the bottom of the article.
The class library does many things, but we're just going to use it to retrieve a contact e-mail users.
Import contacts from MSN MessengerWe are going to achieve this goal by creating a function that returns an ArrayList of 'e-mail that you can use in your website.Here is the function I'm using to import the contacts and returns in an ArrayList:
-----
Public Shared Function GetMessengerContacts (ByVal username As String, ByVal Password As String) As ArrayList
SEmail Dim name As String =
Dim password As String = Spassword
SConnected As Boolean Dim
ICountactsFound As Integer Dim
As New ArrayList Dim AReturn
As DotMSN XihSolutions.DotMSN.Messenger = New XihSolutions.DotMSN.Messenger
DotMSN.Credentials.Account = sEmail
DotMSN.Credentials.Password = Spassword
DotMSN.Credentials.ClientID = "msmsgs@msnmsgr.com"
DotMSN.Credentials.ClientCode = "Q1P7W2E4J9R8U3S5"
Test
DotMSN.Connect ()
System.Threading.Thread.Sleep (10000)
sConnected = DotMSN.Connected
For each contact How XihSolutions.DotMSN.Contact In DotMSN.ContactList.All
aReturn.Add (contact.Mail)
iCountactsFound iCountactsFound = + 1
Next
DotMSN.Disconnect ()
Catch ex As Exception
'There was an error
End Try
Back aReturn
End Function
-----
As you can see it uses the class library, so make sure you have the DotMSN XihSolutions.DotMSN.dll in the bin directory.
You will notice two things that may not have been held, first, that the MSN network and requires a 'ClientCode' 'ClientID' and. Feel free to use what I have provided here. Take note that these you may become invalid in the future, so if this is the case, contact me or do a search for some new ones. I am using these credentials for a couple of years without problems.
Secondly, the row System.Threading.Thread.Sleep (10000) may have caught your attention. Without this pause for 10 seconds, I discovered that only a fraction of the contacts are downloaded. Obviously, the function DotMSN executed asynchronously, and, accordingly, I put in this break to recover it. There are probably ways to make it more clean and precise, but only because any user imports your contacts from time to time does not seem to be a problem.Third you should capture the username and password in a secure environment.
Summary
Simple things is not true - you need a page to the instrument that can pass the email address and password for the function, but that is very simple and needs no explanation. In addition, you must use the ArrayList once populated with email addresses - this is easy: you can store in a database or send email invitations to every e-mail address, or both .......
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment