I am making an application that basically let the user log into its gmail account and send email. My user interface will contain username textbox and password textbox, and log in button. If the user type in the correct username and password, it will take the user to another user interface where the user can send email to another gmail user. What I want to know is, on my first user interface, how can I authenticate the username(gmail username) and password that the user type in? I've been looking over the net how to do it. I could not find it unfortunately. Please help me out. Thanks in advance.
Saing
Saing

Shirsendu NandiRank #246 · 10.2K reputationPosted May 8, 2011, 2:17 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted May 8, 2011, 4:25 AM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted May 8, 2011, 4:35 AM EDT
protected void btnSend_Click(object sender, EventArgs e) { SmtpClient client = new SmtpClient(); MailMessage message = new MailMessage(); client.Port = 587; client.Host = "smtp.gmail.com"; client.UseDefaultCredentials = true; client.Credentials = new System.Net.NetworkCredential(txtemail.Text ,txtpass.Text ); client.EnableSsl = true; try { MailAddress SendTo = new MailAddress(txtTo.Text); MailAddress SendFrom = new MailAddress(txtFrom.Text); message = new MailMessage(SendFrom, SendTo); message.Body = txtMessage.Text; message.Subject = txtSub.Text; client.Send(message); txtStatus.Text = "Your email has been sent"; Page.RegisterClientScriptBlock("Thanks!", "alert('Mail Sent !')"); } catch (Exception ex) { txtStatus.Text = ex.ToString(); } } }Suthish NairRank #92 · 22.8K reputationPosted May 8, 2011, 5:11 AM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted May 8, 2011, 6:05 AM EDT
when you are sending mail it includes authentication process in SmtpClient class .so if you want to do that process seperatly to check that user have provided Username and password correctly or not then when user provide Username nad pasword in First form just send an email and check if it throws credentials related exception then provided Uname and pass are wrong ..if mails successfully with that credentials then username and password are corerct you can go ahead in next form .when you can send mail using same username password :)