Fetch Contacts From yahoo using asp.net and c#
by chintan prajapati on Oct.31, 2007, under ASP.net, C#, yahoo
From last many days i was searching for a free script for yahoo contacts importer.. but its freely available only for PHP.
so finally i got a blog post(http://gnillydev.blogspot.com/2007/10/yahoo-contact-import-class-in-c.html) having code to fetch contacts from yahoo. i had implemented it in our project as well i had uploaded it on my website.
You can check this example here
Download Source Code (Asp.net 2.0 , C#)
All Vb.net User can convert their code here
ScreenShot:

If any one having such script for Gmail Please leave a comment.
Please go through all comments for before raising question.






November 2nd, 2007 on 4:54 am
Very Good Example….
i was looking for same.
thanks chintan
November 6th, 2007 on 5:21 pm
Nice code! Thanks!
November 14th, 2007 on 2:06 am
Great Code ….
November 16th, 2007 on 7:50 am
i found erro when i am running Code
Error is “Object refrance not set to instance of object”
error is come in given below line of the code
string[] tmp1 = cookie.Split(’,');
Please Help me
ok
Bye
November 16th, 2007 on 7:55 am
thanks man….nice code.
November 18th, 2007 on 10:50 am
does not work for me anymore.. fails in login, does not return the set-cookie header
November 27th, 2007 on 12:16 am
Thanks a lot, the example really helped.
December 10th, 2007 on 12:21 pm
For me the same - doesn’t create cookie. Does anybody know why?
December 12th, 2007 on 6:04 am
Thank you very much.
Your code is working 100% on my live site it is not working in local environment.
Thank you very much,
krunal
December 24th, 2007 on 5:34 am
Thanks a lot.
Great code! Can you please hint me how to grab address book for gmail, AOL, hotmail/msn etc.
Thanks a lot again
December 28th, 2007 on 1:34 am
hey pankaj.
fetching address book is very simple.
here is logic .
1) login to Your Gmail account
2) go to this URL https://mail.google.com/mail/contacts/data/export?exportType=ALL&groupToExport=&exportPhone=true&exportAddress=true&exportEmail=true&out=HTML
here you can see all contacts with their name and email .
same sequence you have to repeat Programmatically.
e.g. First you create request to google accounts , if username pwd is right then set session and cookies accordingly. and at last you create request to desired URL from where you can fetch all contacts.
then you have to extract all email id based on some regular Expression.
that’s it.
January 5th, 2008 on 1:02 am
hi im vijayakumar,
just now i seen your asp code its really good.. i want the same thing to import the address book using php and javascript.. can you help me plz
January 12th, 2008 on 1:45 am
Hey guys..
One good news for asp.net developer..
there’s site called http://www.ideabubbling.com/TestDrive.aspx
is providing asp.net DLL for fetching contacts from
gmail yahoo Hotmail AOL and Rediffmail.
so no need to buy scripts from http://www.octazen.com/
thanks..
February 4th, 2008 on 12:06 am
Hey Guys
This code is very good for yahoo.
but if i want to implement on gmail or hotmail, then i have some diffculty.
plz send me code for gmail or hotmail in asp.net.
Tool of converion of c# and asp.net is also very good.
Thanks
Kamal Jindal
February 15th, 2008 on 2:00 am
Hi Chintan ,
Thanks a lot for your cooperation,
http://www.ideabubbling.com/TestDrive.aspx
still i hvn’t test it but hope it works.
Thanks again.
Pradeep Mehta.
March 8th, 2008 on 4:07 am
Thank you,
Is there any utility to extract gmail and other addresses?
Thanks & Regards,
Amar Dhembare
March 27th, 2008 on 11:21 pm
I have test the lib from ideabuilding.com. It works well. Enjoy it!
April 10th, 2008 on 8:06 am
hey !!!
its a vary nice example it works for me to import yahoo contacts….
If you want to import gmail hotmail visit
http://www.ideabubbling.com/TestDrive.aspx
they provides free code for all of them…
Anil Pandya
Software Programmer
Mumbai - India
May 16th, 2008 on 12:07 am
Hello friends,
i am working on a task that “Import Address Book from indiatimes.com in Dot Net (C#).”
in this module, i solved the login process, but i cannot get the contact.csv file.
can u tell me
here is my code
string strLoginUrl = “http://integra.indiatimes.com/Times/Logon.aspx?ru=” + HttpContext.Current.Server.UrlEncode(”http://infinite.indiatimes.com/cgi-bin/gateway”) + “&IS=058f3c27-6793-41c7-a676-81e3f3594a5c&NS=email&HS=kSVLJ96CWWzEmTwPZa1LD6YR7NM=”;
string strLoginUrlPost = “op=login&login=” + strUserid + “&passwd=” + strPassword + “&rememberme=&rememberPwd=&Sign+In=”;
HttpWebRequest webReqLogin = (HttpWebRequest)WebRequest.Create(strLoginUrl);
webReqLogin.Method = Utility.Post;
webReqLogin.UserAgent = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
webReqLogin.KeepAlive = true;
webReqLogin.AllowAutoRedirect = false;
webReqLogin.UseDefaultCredentials = true;
webReqLogin.CookieContainer = new CookieContainer();
webReqLogin.ContentLength = strLoginUrlPost.Length;
webReqLogin.ContentType=”application/x-www-form-urlencoded”;
StreamWriter sw = new StreamWriter(webReqLogin.GetRequestStream(), System.Text.Encoding.ASCII);
sw.Write(strLoginUrlPost); sw.Close();
HttpWebResponse webResLogin = (HttpWebResponse)webReqLogin.GetResponse();
webResLogin.Cookies = webReqLogin.CookieContainer.GetCookies(webReqLogin.RequestUri);
//string strNewResponseUrl = webResLogin.StatusDescription;
StreamReader sr = new StreamReader(webReqLogin.GetResponse().GetResponseStream());
String strMainPage = sr.ReadToEnd();
sr.Close();
CookieCollection ccWebReqLogin = new CookieCollection();
ccWebReqLogin.Add(webResLogin.Cookies);
//webResLogin.Close();
//webReqLogin.Abort();
string strAddressBookRequestUrl = webResLogin.ResponseUri.ToString();
string strAddressBookRefererUrl = “http://tilmb19.indiatimes.com/h/search?st=contact”;
//2========================================================================================
HttpWebRequest webReqAddress = (HttpWebRequest)WebRequest.Create(strAddressBookRequestUrl);
webReqAddress.Method = Utility.Get;
webReqAddress.UserAgent = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
webReqAddress.Referer = webResLogin.ResponseUri.ToString();
webReqAddress.CookieContainer = new CookieContainer();
webReqAddress.CookieContainer.Add(ccWebReqLogin);
HttpWebResponse webResAddress = (HttpWebResponse)webReqAddress.GetResponse();
webResAddress.Cookies = webReqAddress.CookieContainer.GetCookies(webReqAddress.RequestUri);
StreamReader sr2 = new StreamReader(webResAddress.GetResponseStream());
string strAddressXml = sr2.ReadToEnd();
if (strAddressXml == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
sr2.Close();
//webResAddress.Close();
//webReqAddress.Abort();
CookieCollection ccWebReqLogin2 = new CookieCollection();
ccWebReqLogin2.Add(webResAddress.Cookies);
strAddressBookRequestUrl = “http://tilmb19.indiatimes.com”;
strAddressBookRefererUrl = “http://tilmb19.indiatimes.com/h/search?st=contact”;
//2========================================================================================
HttpWebRequest webReqAddress2 = (HttpWebRequest)WebRequest.Create(strAddressBookRequestUrl);
webReqAddress2.UserAgent = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
webReqAddress2.Referer = webResAddress.ResponseUri.ToString();
webReqAddress2.CookieContainer = new CookieContainer();
webReqAddress2.ContentType = “application/x-www-form-urlencoded”;
webReqAddress2.CookieContainer.Add(ccWebReqLogin);
webReqAddress2.CookieContainer.Add(ccWebReqLogin2);
webReqAddress2.AllowAutoRedirect = true;
StreamReader sr21 = new StreamReader(webReqAddress2.GetResponse().GetResponseStream());
strAddressXml = sr21.ReadToEnd();
if (strAddressXml == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
sr21.Close();
webReqAddress2.Abort();
Kamal Jindal
+91 999 110 1929
June 30th, 2008 on 1:24 am
hi friends this code give error in hotmail and rediffmail address book import …………… can you please give the solution for the same
July 10th, 2008 on 9:28 am
hi chintan,
nice code! I love it!
One question for ya: I’m trying to pop up a new window after getting the users credentials (i.e. to Yahoo) and have it auto log them? Obviously in your code here, you get into Yahoo and download the address book. Is there a way to keep them signed in?
Thanks in advance! Again, very nice work!
-Mike
July 24th, 2008 on 12:06 pm
This is best till now i have seen
http://www.ideabubbling.com/TestDrive.aspx
let me know somthing better then this
but not having orkut ,hi5 … etc
plzzzzzzzzzzzzzzz let me know if any 1 find
vijay
(vj)
September 13th, 2008 on 8:29 am
Thanx 4 this code (free)
I am in extreme need of this code..
Thx a lot.
October 4th, 2008 on 5:29 am
Really nice, this was i am expecting, great chintan
October 15th, 2008 on 2:43 am
hey,
its was awesome
do you know how to check users status in yahoo messenger
help me;)
October 18th, 2008 on 5:26 am
I am planning to implement this in my website http://www.forums.itchytech.net
I tried the sample but it only got 9 of my contacts instead of getting all of my contacts. Please let me know if I need to modify something in the code… Not that good at programming…
Thanks…
Thanks for sharing… I hope there’s also a code to extract contacts from hotmail and gmail.
October 21st, 2008 on 5:43 am
Hi you did the fabulous job
Thanks
But is it any way to find active contact list of logged user s or unloged users.
Thanks in Advance
November 12th, 2008 on 10:53 am
Excelent Work Dude
November 24th, 2008 on 1:51 am
Hi
Thanks for the code. Its working fine.
Can U pls let me know how to do the same for gmail & hotmail.
Thanks in advance!!!
–Sireesha
January 22nd, 2009 on 11:22 pm
Nice work man its work fine i was looking for same
Thank you
March 6th, 2009 on 4:21 am
Hi,
I am using java in my website.
How can I fetch the contacts?
May 5th, 2009 on 12:15 am
Hi,
Thanks for the code. Its working fine for Yahoo, Gmail and AOL. But not working for Hotmail.
Can u pls help about hotmail.
Thanks in advance!!
June 18th, 2010 on 5:12 am
Hi,
Plz Help me out this code is not working,
i want to import contact from yahoo and Outlook through ASP.net,C#
Plz help me
Thanks in advance
August 10th, 2010 on 1:31 am
This one works and is very reliable, they actually test it and publish their results online. Does all the major ones. We use it on our site and is great.
http://www.socialcontactsimporter.net