How to log into webmail?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

How do I perform a web form submission in a windows form and get the
submitted page into a variable? For example, I'd like to create a Win Form
that has a username and pass. Once the Win Form's login button is clicked,
it will log into a web mail account. I will parse the first page (message
list) and display it in another Win Form.

Thanks,
Brett
 
Brett said:
How do I perform a web form submission in a windows form and get the
submitted page into a variable? For example, I'd like to create a Win
Form that has a username and pass. Once the Win Form's login button is
clicked, it will log into a web mail account. I will parse the first page
(message list) and display it in another Win Form.

\\\
Imports System.IO
Imports System.Net
..
..
..
Dim wrq As WebRequest = _
WebRequest.Create("https://example.org/shop/order.jsp")
wrq.Credentials = New NetworkCredential("username", "password")
Dim wrp As WebResponse = wrq.GetResponse()
Dim sr As New StreamReader(wrp.GetResponseStream())
MessageBox.Show(sr.ReadToEnd())
sr.Close()
wrp.Close()
///

Replace the URL, "username" and "password" with appropriate values.

For parsing the HTML file:

MSHTML Reference
<URL:http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp>

- or -

..NET Html Agility Pack: How to use malformed HTML just like it was
well-formed XML...
<URL:http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx>

Download:

<URL:http://www.codefluent.com/smourier/download/htmlagilitypack.zip>

If the file read is in XHTML format, you can use the classes contained in
the 'System.Xml' namespace for reading information from the file.
 
Herfried K. Wagner said:
\\\
Imports System.IO
Imports System.Net
.
.
.
Dim wrq As WebRequest = _
WebRequest.Create("https://example.org/shop/order.jsp")
wrq.Credentials = New NetworkCredential("username", "password")
Dim wrp As WebResponse = wrq.GetResponse()
Dim sr As New StreamReader(wrp.GetResponseStream())
MessageBox.Show(sr.ReadToEnd())
sr.Close()
wrp.Close()
///

Replace the URL, "username" and "password" with appropriate values.

For parsing the HTML file:

MSHTML Reference
<URL:http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp>

- or -

.NET Html Agility Pack: How to use malformed HTML just like it was
well-formed XML...
<URL:http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx>

Download:

<URL:http://www.codefluent.com/smourier/download/htmlagilitypack.zip>

If the file read is in XHTML format, you can use the classes contained in
the 'System.Xml' namespace for reading information from the file.
I tried your code but only get the login page. It doesn't return the page
after login, which means it isn't logging in. I was trying the following
code but getting the same results:

Dim myclient As System.Net.WebClient = New System.Net.WebClient
myclient.Headers.Add("Content-Type", "text/html;
charset=ISO-8859-1")

Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes("[email protected]&password=somepass&jsCapable=1&frames=0&LOCALE=en_US&VARIANT=")
Dim res As Byte() =
myclient.UploadData("http://netmail.verizon.net/en_US/agent/moblogin",
"POST", d)

Me.rtxtShowWebpage.Text = System.Text.Encoding.ASCII.GetString(res)

You can see above I'm submitting all the login page form variables. Is this
a cookie issue? How is that handled?

Thanks,
Brett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top