Mr.Wobbles 0 Light Poster

Hi, I have two things that if I can do one I won't need to do the other, so whichever is easiest you guys answer me either way. What I am trying to do is get text from an email and download it into a text file on my computer. I have tried going in through the server and end up with a (440) Login Timeout Error, also I have tried just using a web browser in the VB form and downloading the text from the email when the user opens it. I can't get either to work correctly.

Here is the code for downloading the text from the email after the user opens it:

Private Sub getEmail()

        'Dim oWrite As StreamWriter
        'Dim URL As String
        Dim userName As String = "S252430"
        Dim webClient As New WebClient()
        Dim strNum As String = ""
        Dim URL As String

        Dim i As Integer = 1

            URL = "" & userName & "/Inbox/Check" & strNum & ".EML/?cmd=body&Security=2&unfiltered=1"

            Dim req As WebRequest = WebRequest.Create(URL)

            Dim rsp As WebResponse = CType(req.GetResponse, HttpWebResponse)

            Dim rdr As New StreamReader(rsp.GetResponseStream())

            Dim txtAsString = rdr.ReadLine


            i += 1
            strNum = "-" & i
        Loop While i < 4

    End Sub

And the code to get into an email account:

Dim userPass As String = Me.password.Text
        Dim userName As String = Me.username.Text

        If userName = "" Or userPass = "" Then

            MsgBox("Please enter user information")

            Dim strServerName As String = ""
            Dim strDomain As String = "Mail.server.domain"
            Dim strUserID As String = userName & ""
            Dim strPassword As String = userPass
            Dim strUserName As String = userName
            Dim term As String = "test"

            ' Create our destination URL.
            Dim strURL As String = "https://" & strServerName & "/exchange/" & strUserName & "/Inbox"

            ' Enter your WebDAV-related code here.
            Dim QUERY As String = "<?xml version=""1.0""?>" _
                   & "<g:searchrequest xmlns:g=""DAV:"">" _
                   & "<g:sql>SELECT ""urn:schemas:httpmail:subject"", " _
                   & """urn:schemas:httpmail:from"", ""DAV:displayname"", " _
                   & """urn:schemas:httpmail:textdescription"" " _
                   & "FROM SCOPE('shallow traversal of """ & strURL & """') " _
                   & "WHERE ""DAV:ishidden"" = False AND ""DAV:isfolder"" = False " _
                   & "AND ""urn:schemas:httpmail:subject"" LIKE '%" & term & "%' " _
                   & "ORDER BY ""urn:schemas:httpmail:date"" DESC" _
                   & "</g:sql></g:searchrequest>"

            Dim Response As System.Net.HttpWebResponse
            Dim RequestStream As System.IO.Stream
            Dim ResponseStream As System.IO.Stream
            Dim ResponseXmlDoc As System.Xml.XmlDocument
            Dim SubjectNodeList As System.Xml.XmlNodeList
            Dim SenderNodeList As System.Xml.XmlNodeList
            Dim BodyNodeList As System.Xml.XmlNodeList
            Dim URLNodeList As System.Xml.XmlNodeList

            Dim Request As HttpWebRequest = CType(System.Net.WebRequest.Create(strURL), _
            Request.CookieContainer = New CookieContainer()

            Request.CookieContainer.Add(AuthenticateSecureOWA(strServerName, strDomain, strUserID, strPassword))

            Request.Credentials = New System.Net.NetworkCredential( _
            strUserName, strPassword, strDomain)

            Request.Method = "SEARCH"
            Request.ContentType = "text/xml"
            Request.KeepAlive = True
            Request.AllowAutoRedirect = False

            Dim bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(QUERY)
            Request.Timeout = 30000
            Request.ContentLength = bytes.Length
            RequestStream = Request.GetRequestStream()
            RequestStream.Write(bytes, 0, bytes.Length)
            Request.Headers.Add("Translate", "F")

            Response = Request.GetResponse

            ResponseStream = Response.GetResponseStream()

            ' Create the XmlDocument object from the XML response stream.
            ResponseXmlDoc = New System.Xml.XmlDocument()
            SubjectNodeList = ResponseXmlDoc.GetElementsByTagName("d:subject")
            SenderNodeList = ResponseXmlDoc.GetElementsByTagName("d:from")
            URLNodeList = ResponseXmlDoc.GetElementsByTagName("a:href")
            BodyNodeList = ResponseXmlDoc.GetElementsByTagName("d:textdescription")
        End If

I colored the line of code that throws the 440 error. Any help is appreciated

Guess I should let you know what I am using - VB 2005 Express (I assume it is .NET) and Outlook Web Access Exchange Server 2003