Imports CDO Imports ADODB Namespace Framework Public Class MHTML Public cCookie As String = "" Public cLoginUrl As String = "" Public cMHTMLUrl As String = "" Public cPassword As String = "" Public cSaveFile As String = "" Public cUsername As String = "" Public oApp As Framework.App ' Collection to hold the form fields to be used when there is a login page Private oFormField As Collection = New Collection ' CDO message object Private oMessage As CDO.Message = New CDO.Message Private oProcess As Framework.LXProcess ' This is when we access the class in a desktop mode Sub New(ByVal toApplication As Framework.App) oApp = toApplication End Sub ' This is when we access the class in a Web or Web Service mode Public Sub New(ByVal toProcess As Framework.LXProcess) oProcess = toProcess oApp = oProcess.oApp End Sub ' Do the login Private Function Login() As Boolean Dim lcCookie As String = "" Dim lcPostData As String = "" Dim llSuccess As Boolean = False 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 loFormField(2) As Object Dim loStreamWebRequest As IO.Stream Dim loWebRequest As System.Net.HttpWebRequest Dim loWebResponse As System.Net.HttpWebResponse ' Get the post data For Each loFormField In oFormField ' If we have a post If lcPostData.Length > 0 Then lcPostData = lcPostData + "&" End If lcPostData = lcPostData + loFormField(1) + "=" + loFormField(2) Next loByte = loASCIIEncoding.GetBytes(lcPostData) ' Prepare Web request loWebRequest = System.Net.WebRequest.Create(cLoginUrl) loWebRequest.Method = "POST" loWebRequest.ContentType = "application/x-www-form-urlencoded" loWebRequest.ContentLength = lcPostData.Length ' Send the data loStreamWebRequest = loWebRequest.GetRequestStream() loStreamWebRequest.Write(loByte, 0, loByte.Length) loStreamWebRequest.Close() loWebRequest.CookieContainer = New System.Net.CookieContainer() ' Get the cookie loWebResponse = loWebRequest.GetResponse() loCookieCollection = loWebRequest.CookieContainer.GetCookies(loWebRequest.RequestUri) ' For each cookie in the collection For lnCounter = 0 To loCookieCollection.Count - 1 lcCookie = loCookieCollection.Item(lnCounter).Name ' If this is the cookie If lcCookie = cCookie Then lcCookie = loCookieCollection.Item(lnCounter).Value ' Define the cookie oMessage.Configuration.Fields.Item(CDO.CdoConfiguration.cdoHTTPCookies).Value = _ cCookie + "=" + lcCookie oMessage.Configuration.Fields.Update() Exit For End If Next llSuccess = True Return llSuccess End Function ' Get the MHTML file Public Function GetMHTML() As Boolean Dim llSuccess As Boolean = False Dim loStream As ADODB.Stream ' If we have something in the collectin If oFormField.Count > 0 Then ' Do the login If Not Login() Then Return False End If End If ' Go get the page oMessage.CreateMHTMLBody(cMHTMLUrl, CDO.CdoMHTMLFlags.cdoSuppressNone, "", "") loStream = oMessage.GetStream() ' Save to file loStream.SaveToFile(cSaveFile, SaveOptionsEnum.adSaveCreateOverWrite) llSuccess = True Return llSuccess End Function ' Add a form field for the post that can be used to do the login ' expC1 Name ' expC2 Value Public Function AddFormField(ByVal tcName As String, ByVal tcValue As String) As Boolean Dim loFormField(2) As Object loFormField(1) = tcName loFormField(2) = tcValue oFormField.Add(loFormField) Return True End Function End Class End NamespaceIn the GetMHTML() method, you can see I need those two. I do not know if there is someting simpler than that.