Zoom Asp.net

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.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google
  • Technorati
34 comments for this entry:
  1. sajesh

    Very Good Example….
    i was looking for same.
    thanks chintan

  2. Skale

    Nice code! Thanks!

  3. anup

    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

  4. manoj

    thanks man….nice code. :)

  5. jaspreet

    does not work for me anymore.. fails in login, does not return the set-cookie header

  6. Arun

    Thanks a lot, the example really helped. :)

  7. M

    For me the same - doesn’t create cookie. Does anybody know why?

  8. krunal

    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

  9. Pankaj

    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

  10. chintan prajapati

    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.

  11. vijayakumar

    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

  12. chintan prajapati

    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..

  13. Kamal Jindal

    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

  14. Pradeep

    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.

  15. Amar Dhembare

    Thank you,

    Is there any utility to extract gmail and other addresses?

    Thanks & Regards,

    Amar Dhembare

  16. ThinhPhung

    I have test the lib from ideabuilding.com. It works well. Enjoy it!

  17. Anil Pandya

    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

  18. Kamal Jindal

    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

  19. rajkumar

    hi friends this code give error in hotmail and rediffmail address book import …………… can you please give the solution for the same

  20. Mike

    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

  21. Vj

    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)

  22. Arjit

    Thanx 4 this code (free)

    I am in extreme need of this code..
    Thx a lot.

  23. Muthukumar

    Really nice, this was i am expecting, great chintan

  24. soroush

    hey,
    its was awesome
    do you know how to check users status in yahoo messenger
    help me;)

  25. Trigun

    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.

  26. Durgesh

    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

  27. Sireesha

    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

  28. Vijayaraya

    Nice work man its work fine i was looking for same
    Thank you

  29. Rajeswari

    Hi,
    I am using java in my website.
    How can I fetch the contacts?

  30. Naresh

    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!!

  31. vish

    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

  32. Patrick

    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

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Failed creating file mapping PHP Fatal error: Failed creating file mapping in Unknown on line 0 PHP Fatal error: XCache: Cannot create shm in Unknown on line 0