Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (StreamReader reader = new StreamReader(openFileDialog1.FileName))
- {
- int count = 0;
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- UserData d = new UserData();
- string[] parts = line.Split(':');
- count = parts.Length;
- d.UserName = parts[0].Trim();
- d.Password = parts[1].Trim();
- data.Add(d);
- }
- foreach(UserData ud in data)
- {
- textBox1.Text += ("LOL" + ud.UserName + ud.Password + Environment.NewLine);
- }
- ------------------------------------
- try
- {
- if (data.Count() == 0)
- {
- MessageBox.Show("Load user info first");
- return;
- }
- var url = @"https://mail.google.com/mail/feed/atom";
- var encoded = TextToBase64(data[0].UserName + ":" + data[0].Password);
- var myweb = HttpWebRequest.Create(url) as HttpWebRequest;
- myweb.Method = "POST";
- myweb.ContentLength = 0;
- myweb.Headers.Add("Authorization", "Basic " + encoded);
- var response = myweb.GetResponse();
- var stream = response.GetResponseStream();
- textBox1.Text += ("Connection established with" );
- }
- catch (Exception ex)
- {
- textBox1.Text += ("Error connection. Original error: " + ex.Message);
- }
- }
- public static string TextToBase64(string sAscii)
- {
- System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
- byte[] bytes = encoding.GetBytes(sAscii);
- return System.Convert.ToBase64String(bytes, 0, bytes.Length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement