By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

gmail authentication using c#

P: 13
hi all
i want to access gmail programatically using c#.
i will just enter my email id & password. if the email id & password is true then the server will give me a response.
pls help me
thanks in advance
Feb 17 '09 #1
Share this Question
Share on Google+
3 Replies


Plater
Expert 5K+
P: 7,872
Turn on SMTP/POP/IMAP in your gmail configuration and then you can connect to it using the SMTP controls, or through outlook(and its interop)
Feb 17 '09 #2

P: 13
hi all
i want to access gmail programatically using c#.
i will just enter my email id & password. if the email id & password is true then the server will give me a response.
but its giving me error the remote server returned an error 403
pls help me
thanks in advance
Expand|Select|Wrap|Line Numbers
  1. NameValueCollection nvc = new NameValueCollection();
  2.                     nvc.Add("accountType", "HOSTED_OR_GOOGLE");
  3.                     nvc.Add("Email", "dllcheck@gmail.com");
  4.                     nvc.Add("Passwd", "dllcheck123");
  5.                     nvc.Add("service", "cl");
  6.                     nvc.Add("source", "Gulp-CalGulp-1.05");
  7.  
  8.                     WebClient client = new WebClient();
  9.  
  10.  
  11.                         byte[] Response = client.UploadValues("http://www.google.com/accounts/ClientLogin",nvc);
  12.                         string s = Encoding.Default.GetString(Response);
  13.                         MessageBox.Show(s);
  14.  
  15.  
  16.              //   http://www.google.com/accounts/ClientLogin/accountType=HOSTED_OR_GOOGLE&Email=jondoe@gmail.com&Passwd=north23AZ&service=cl&source=Gulp-CalGulp-1.05
  17.  
  18.                    HttpWebRequest webreqAuthenticate = (HttpWebRequest)WebRequest.Create("http://www.google.com/accounts/ClientLogin");
  19.                     webreqAuthenticate.ContentType = "application/x-www-form-urlencoded";
  20.  
  21.                     webreqAuthenticate.Method = "POST";
  22.  
  23.                     webreqAuthenticate.ContentLength = 200;
  24.  
  25.                     //webreqAuthenticate.Timeout = 6000;
  26.  
  27.                     webreqAuthenticate.AllowAutoRedirect = true;
  28.  
  29.                     webreqAuthenticate.MaximumAutomaticRedirections = 10;
  30.  
  31.                     HttpWebResponse webresAuthenticate = webreqAuthenticate.GetResponse() as HttpWebResponse;
  32.  
  33.                     Stream streamResponse = webresAuthenticate.GetResponseStream();
  34.  
pls help
thanks in advance
Feb 18 '09 #3

Plater
Expert 5K+
P: 7,872
Pretty sure google uses secure http, https:// designators so you will have to account for that.

But I would say a better way would be to just look up the google API code for this, since they released all of that for free(you might need an API key)
Feb 19 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.