locked
open gmail account given username and password dynamically in asp.net C# RRS feed

  • Question

  • User993120701 posted

    Hi,

    I my project, if click a button, I want to login gmail account with username and password directly.

    Pl help on this.

    protected void Button3_Click(object sender, EventArgs e)
    {

    string userName = "abc";
    string password = "abc";

    string hdr = "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + password)) + System.Environment.NewLine;
    webbrowser.navigate(String.Format("http://{0}:{1}@gmail.com/login", userName, password), null, null, hdr);

     }

    error is shown on webbrowser. could not found.

    Pl guide on this process.

    Monday, March 9, 2015 12:32 AM

Answers

  • User2103319870 posted

    lathasekar

    webbrowser.navigate(String.Format("http://{0}:{1}@gmail.com/login", userName, password), null, null, hdr);

    Are you trying to use WebBrowser.navigate in a web application or windows application. if its for webapplcation then you need to use Response.Redirect instead of WebBrowser.navigate.

    protected void Button3_Click(object sender, EventArgs e)
            {
    
                string userName = "abc";
                string password = "abc";
    
                string hdr = "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + password)) + System.Environment.NewLine;
                Response.Redirect(String.Format("http://{0}:{1}@gmail.com/login", userName, password));
    
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 9, 2015 12:40 AM
  • User-434868552 posted

    @lathasekar

    Why do you "want to login to GMail account with username and password directly"?

    what do you mean when you write that you "want to login to GMail account with username and password directly"?

    lathasekar, do you want to programmatically 

    (a) send e-mail using a GMail account?

    (b)  read e-mail using a GMail account?

    (c) both?

    for (a), you want to do something like this:  http://forums.asp.net/post/5863714.aspx 

               see also http://forums.asp.net/post/5869653.aspx 

    (b) is more complicated ... search           c# read gmail programmatically

                 example:  https://social.msdn.microsoft.com/forums/windowsapps/en-us/8bedca72-d00c-4eef-9d97-af26a8e0719e/reading-messages-from-gmail 

    lathasekar, both sending e-mail and receiving e-mail, in fact doing anything on the internet means you have to follow internet protocols:

    send:  SMTP http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol 

    send:  POP3 http://en.wikipedia.org/wiki/Post_Office_Protocol 

    send:  IMAP http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol 

    POP3 is for when you want to store your e-mail on your client computer

    IMAP is for when you want to keep your e-mails on the e-mail server (and synchronize what's on the e-mail server with what's on one or more client computers).

    http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

        "Clarity is important, both in question and in answer"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 9, 2015 3:23 AM
  • User-434868552 posted

    @lathasekar

    whatever you are trying to do likely will not work imho at least from what you have shown us to date.

    your peers have asked you questions but you do not answer those questions thoughtfully.  FWIW

    you do not appear to understand the nature of web applications in general.

    generally, web applications work in two universes ... the client side (the end user's browser) and the server side (the computer that hosts the website)

    localhost is simply a convenience for hosting both universes on the same computer for the purpose of testing.

    if you try to use localhost from a remote server to localhost on port 8080 on your computer, that is not possible:

    "local" has the same meaning for every computer ...  my localhost is not your localhost ...

    when i say me i am talking about myself; when you say me your are talking about yourself.

    you can not encrypt the username and password for GMail ... you must allow the HTTPS (HTTP with SSL or TLS) to do that!

    http://en.wikipedia.org/wiki/HTTPS 

    lathasekar, again, i suggest that you thoughtfully read http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

    also, you are not being sent links by your peers because your peers enjoy sending links; links are sent to you to help you but you can not be helped if you do not take your own time to understand them.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 10, 2015 8:46 AM

All replies

  • User2103319870 posted

    lathasekar

    webbrowser.navigate(String.Format("http://{0}:{1}@gmail.com/login", userName, password), null, null, hdr);

    Are you trying to use WebBrowser.navigate in a web application or windows application. if its for webapplcation then you need to use Response.Redirect instead of WebBrowser.navigate.

    protected void Button3_Click(object sender, EventArgs e)
            {
    
                string userName = "abc";
                string password = "abc";
    
                string hdr = "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + password)) + System.Environment.NewLine;
                Response.Redirect(String.Format("http://{0}:{1}@gmail.com/login", userName, password));
    
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 9, 2015 12:40 AM
  • User2103319870 posted

    if you are using the above code in a windows application. Then this question is offtopic here as this forums is for asp.net questions. 

    You may consider posting your question in windows forum from MSDN

    Monday, March 9, 2015 12:44 AM
  • User993120701 posted

    Hi,

    I tried this. URL is opening without logged in directly. just showing login page.

    Pl guide.

    Monday, March 9, 2015 1:00 AM
  • User-434868552 posted

    @lathasekar

    Why do you "want to login to GMail account with username and password directly"?

    what do you mean when you write that you "want to login to GMail account with username and password directly"?

    lathasekar, do you want to programmatically 

    (a) send e-mail using a GMail account?

    (b)  read e-mail using a GMail account?

    (c) both?

    for (a), you want to do something like this:  http://forums.asp.net/post/5863714.aspx 

               see also http://forums.asp.net/post/5869653.aspx 

    (b) is more complicated ... search           c# read gmail programmatically

                 example:  https://social.msdn.microsoft.com/forums/windowsapps/en-us/8bedca72-d00c-4eef-9d97-af26a8e0719e/reading-messages-from-gmail 

    lathasekar, both sending e-mail and receiving e-mail, in fact doing anything on the internet means you have to follow internet protocols:

    send:  SMTP http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol 

    send:  POP3 http://en.wikipedia.org/wiki/Post_Office_Protocol 

    send:  IMAP http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol 

    POP3 is for when you want to store your e-mail on your client computer

    IMAP is for when you want to keep your e-mails on the e-mail server (and synchronize what's on the e-mail server with what's on one or more client computers).

    http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

        "Clarity is important, both in question and in answer"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 9, 2015 3:23 AM
  • User993120701 posted

    Thanks for your valuable suggestions.

    I have hosted the web app in the local host say ex (http://localhost/8080/login)

    Now from online web application we have to redirect the localhost with user name and password. Only webpage is opening not logged in. Pl guide on this.

    protected void btnthruftp_Click(object sender, EventArgs e)
    {
         string name = HttpUtility.UrlEncode(Encrypt(userId));
         string technology = HttpUtility.UrlEncode(Encrypt(pwd));
         Response.Redirect("ftp://name:technology@localhost:8080/login/");

    }

    Tuesday, March 10, 2015 4:06 AM
  • User-434868552 posted

    @lathasekar

    whatever you are trying to do likely will not work imho at least from what you have shown us to date.

    your peers have asked you questions but you do not answer those questions thoughtfully.  FWIW

    you do not appear to understand the nature of web applications in general.

    generally, web applications work in two universes ... the client side (the end user's browser) and the server side (the computer that hosts the website)

    localhost is simply a convenience for hosting both universes on the same computer for the purpose of testing.

    if you try to use localhost from a remote server to localhost on port 8080 on your computer, that is not possible:

    "local" has the same meaning for every computer ...  my localhost is not your localhost ...

    when i say me i am talking about myself; when you say me your are talking about yourself.

    you can not encrypt the username and password for GMail ... you must allow the HTTPS (HTTP with SSL or TLS) to do that!

    http://en.wikipedia.org/wiki/HTTPS 

    lathasekar, again, i suggest that you thoughtfully read http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

    also, you are not being sent links by your peers because your peers enjoy sending links; links are sent to you to help you but you can not be helped if you do not take your own time to understand them.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 10, 2015 8:46 AM