C# .NET - How we check gmail,yahoo id with credential using c#

Asked By ALOK RANJAN on 28-May-12 02:46 AM
hi  everyone,
             I have scenario that i want to check  credential of gmail ,yahoo id  means This id is valid ID or not

             using C# . please help me.

Thanks & Best Regards

Somesh Yadav replied to ALOK RANJAN on 28-May-12 02:57 AM
check this,
Suchit shah replied to ALOK RANJAN on 28-May-12 03:19 AM
As per my best knowledge there is a no direct way to check that particular email address is available in Gmail or yahoo database or not... there are few sites available with that you can manually able to check that this is valid email address or not but to implement same functionality in c# is not possible using regular expression you can check that enter email address is valid or not ( means it will follow the rule of standard email address) but you cant able to check that this email address is present in gmail or yahoo database or not 
Jitendra Faye replied to ALOK RANJAN on 28-May-12 03:28 AM
You can complete this task using DotNetOpenAuth.

Here is code for this-

    using DotNetOpenAuth.OpenId; 
    using DotNetOpenAuth.OpenId.RelyingParty; 

    protected void Page_Load(object sender, EventArgs e) 
      OpenIdRelyingParty rp = new OpenIdRelyingParty(); 
      var r = rp.GetResponse(); 
      if (r != null) 
        switch (r.Status) 
          case AuthenticationStatus.Authenticated: 
            NotLoggedIn.Visible = false; 
            Session["GoogleIdentifier"] = r.ClaimedIdentifier.ToString(); 
            Response.Redirect("Main.aspx"); //redirect to main page of your website 
          case AuthenticationStatus.Canceled: 
            lblAlertMsg.Text = "Cancelled."; 
          case AuthenticationStatus.Failed: 
            lblAlertMsg.Text = "Login Failed."; 
    protected void OpenLogin_Click(object src, CommandEventArgs e) 
      string discoveryUri = e.CommandArgument.ToString(); 
      OpenIdRelyingParty openid = new OpenIdRelyingParty(); 
      var b = new UriBuilder(Request.Url) { Query = "" }; 
      var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri); 

for more details follow this link-

dipa ahuja replied to ALOK RANJAN on 28-May-12 06:22 AM
using System.Net.Mail;
using System.Net;
protected void BtnSendMail_Click(object sender, EventArgs e)
    string UserName = "";
    string PassWord="";
    string Reciever = "reciever@gmail.com";
    NetworkCredential loginInfo = new NetworkCredential(UserName, PassWord);
    MailMessage msg = new MailMessage();
    msg.From = new MailAddress(UserName);
    msg.To.Add(new MailAddress(Reciever));
    msg.Subject = txtSubject.Text.ToString();
    msg.Body = txtmsg.Text.ToString();
    msg.IsBodyHtml = true;
    SmtpClient client = new SmtpClient("smtp.gmail.com");
    client.EnableSsl = true;
    client.UseDefaultCredentials = false;
    client.Credentials = loginInfo;
    Response.Write("<script>alert('mail sent')</script>");
  Put the code inside Try..Catch and in the catch block you can display the exception message if the username and password are incorrect