Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More on using cookies with CreateMHTMLBody
Message
From
19/10/2007 13:05:51
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
More on using cookies with CreateMHTMLBody
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01262216
Message ID:
01262216
Views:
102
I have continued on my research to try using cookies with CreateMHTMLBody. Basically, I am using HttpWebRequest to post data to a page. That is creating a cookie. I can read that cookie after. Then, I need to pass that cookie when using CreateMHTMLBody. However, I cannot succeed in doing that. I am using something like this:
    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        Dim loConfiguration As CDO.Configuration = New CDO.Configuration
        Dim loField As ADODB.Fields
        Dim loMessage As CDO.Message = New CDO.Message
        Dim loStream As ADODB.Stream

        Dim lcCookie As String = ""
        Dim lcPassword As String = "transfo"
        Dim lcPostData As String = ""
        Dim lcUsername As String = "mfournier"
        Dim lnCounter As Integer = 0
        Dim loASCIIEncoding As System.Text.Encoding = New System.Text.ASCIIEncoding
        Dim loByte() As Byte
        Dim loCookieCollection As System.Net.CookieCollection
        Dim loCookieContainer As System.Net.CookieContainer = New System.Net.CookieContainer
        Dim loStreamWebRequest As IO.Stream
        Dim loWebRequest As System.Net.HttpWebRequest
        Dim loWebResponse As System.Net.HttpWebResponse

        ...all the code here to post the data and receive the cookie

        For lnCounter = 0 To loCookieCollection.Count - 1
            lcCookie = loCookieCollection.Item(lnCounter).Name
            If lcCookie = "LevelExtremeSession" Then
                lcCookie = loCookieCollection.Item(lnCounter).Value

                ' Define the cookie
                loField = loConfiguration.Fields
                loField(CDO.CdoConfiguration.cdoHTTPCookies).Value = "LevelExtremeSession=" + lcCookie + ";expires=Thu, 01-Jan-2008 00:00:01 GMT;path=/"

            End If
        Next

        ' Make sure we set the cookie
        loMessage.Configuration = loConfiguration

        ' Go get the page
        loMessage.CreateMHTMLBody("http://www.myurl.com/Detail.aspx", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "")
        loStream = loMessage.GetStream()

        ' Save to file
        loStream.SaveToFile("D:\Test.mhtml")

    End Sub
So, there is something with the loField(CDO.CdoConfiguration.cdoHTTPCookies).Value line. I just don't know what is wrong.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform