Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using (StreamReader reader = new StreamReader(openFileDialog1.FileName))
  2. {
  3. int count = 0;
  4. string line;
  5. while ((line = reader.ReadLine()) != null)
  6. {
  7. UserData d = new UserData();
  8. string[] parts = line.Split(':');
  9. count = parts.Length;
  10. d.UserName = parts[0].Trim();
  11. d.Password = parts[1].Trim();
  12. data.Add(d);
  13. }
  14.  
  15. foreach(UserData ud in data)
  16. {
  17. textBox1.Text += ("LOL" + ud.UserName + ud.Password + Environment.NewLine);
  18. }
  19.  
  20. ------------------------------------
  21.  
  22. try
  23. {
  24. if (data.Count() == 0)
  25. {
  26. MessageBox.Show("Load user info first");
  27. return;
  28.  
  29.  
  30.  
  31. }
  32.  
  33. var url = @"https://mail.google.com/mail/feed/atom";
  34. var encoded = TextToBase64(data[0].UserName + ":" + data[0].Password);
  35. var myweb = HttpWebRequest.Create(url) as HttpWebRequest;
  36. myweb.Method = "POST";
  37. myweb.ContentLength = 0;
  38. myweb.Headers.Add("Authorization", "Basic " + encoded);
  39. var response = myweb.GetResponse();
  40. var stream = response.GetResponseStream();
  41. textBox1.Text += ("Connection established with" );
  42. }
  43. catch (Exception ex)
  44. {
  45. textBox1.Text += ("Error connection. Original error: " + ex.Message);
  46.  
  47. }
  48.  
  49.  
  50. }
  51.  
  52. public static string TextToBase64(string sAscii)
  53. {
  54. System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
  55. byte[] bytes = encoding.GetBytes(sAscii);
  56. return System.Convert.ToBase64String(bytes, 0, bytes.Length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement