Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Access Outlook Web Redirection , +
hi all,
 
i am not able to redirect/login to my owa page. when i run my code below commandd windoe comes and disappears nothing happens.
 
please seemy code below
 

Sub main()
 
    Dim strServerName As String = "12.345.56.789" ' my owa ip
    Dim strPassword As String = "password" 'my password
    Dim strUserName As String = "username" ' my username

    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)
    Dim strURL As String = "https://" & strServerName & "/exchange/"
    ''Dim strURL As String = "https://" & strServerName & "/owa/"
    Dim Response As System.Net.HttpWebResponse
    Dim RequestStream As System.IO.Stream
    Dim ResponseStream As System.IO.Stream
 
    Dim WebReq As HttpWebRequest = CType(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
    WebReq.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
    Try
        WebReq.Method = "POST"
        WebReq.ContentType = "text/xml"
        WebReq.KeepAlive = True
        WebReq.AllowAutoRedirect = False
 

        Dim AuthUrl As System.Uri
 
        AuthUrl = New System.Uri("https://" + strServerName + "/exchweb/bin/auth/owaauth.dll")
        cookieJar = New CookieContainer
 
        WebReq.CookieContainer = cookieJar
 
        Dim strPostFields As String = "destination=https%3A%2F%2F" & strServerName & "%2Fowa%2F"
        Dim PostData() As Byte = System.Text.Encoding.ASCII.GetBytes(strPostFields)
 
        ' Set the content length.
        WebReq.ContentLength = PostData.Length
        Dim tmpStream As Stream
        Try
            ' Create a request stream. Write the post data to the stream.
            tmpStream = WebReq.GetRequestStream()
            tmpStream.Write(PostData, 0, PostData.Length)
            tmpStream.Close()
 
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString())
        End Try
 

        ' Get the response from the request.
        Dim WebResp As HttpWebResponse = WebReq.GetResponse()
        WebResp.Close()
 
        'WebReq.Timeout = 30000
        'ResponseStream = WebReq.GetRequestStream()
        'Response1 = WebReq.GetResponse()
    Catch ex As Exception
        MessageBox.Show(ex.Message.ToString())
    End Try
 
End Sub
Posted 9-Nov-12 21:48pm
kk20141.8K

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 265
1 Sergey Alexandrovich Kryukov 202
2 George Jonsson 185
3 King Fisher 185
4 CPallini 155
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 10 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100