Download files from HTTPS Site that requires Login

I'm writing an App in VB6 that opens up an IE browser using the InternetExplorer object, then navigates to a https site, fills in the username and password fields and clicks the button to log in.
From there it navigates to a page within the site which contains a list of files (.PDF, .ZIP and .DOC files). I need an automated way to download this list of files, but I'm yet to find a way to do this. This also has to be done through an Authenticated Proxy.

I tried URLDownloadToFile, but it didn't work because I couldn't work out how to use it with authentication information (either for the website OR the Proxy). Can anyone clue me in here?

I'm trying to use the Internet Transfer Control, but I can't get that to work either.
Here's the code I'm using:

    Dim FileURL As String
    Dim i As Integer
    Dim b() As Byte
    Dim h As Integer

    Form1.Inet1.protocol = icHTTPS
    Form1.Inet1.UserName = Website_Username
    Form1.Inet1.Password = Website_Password
    Form1.Inet1.Proxy = Proxy_IP_Address
    Form1.Inet1.AccessType = icNamedProxy
    FileURL = ""
    b = Form1.Inet1.OpenURL(FileURL, icByteArray)
    h = FreeFile
    Open "D:\" For Binary As #h
    Put #h, , b
    Close #h
    Debug.Print Form1.Inet1.ResponseCode & " Error Info : " & Form1.Inet1.ResponseInfo

If I don't set the Proxy and AccessType properties, it downloads a html file that tells me I failed to authenticate with the proxy server (the same one I see if I put in my username or password incorrectly in my web browser when accessing the interent normally). If I do set these properties, i get the debug message: "12029 Error Info : Cannot connect". Does anyone know how to set proxy username and password values with this control? I also should be connecting to the proxy on port 8080 - anyone know how this can be done?

Or, alternately, is there another way to download files in this situation? Is it possible to use the InternetExplorer Object to do it somehow?

Thanks for any help you can offer,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this...

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
   Dim lngRetVal As Long
   lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
   If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
   DownloadFile "", "c:\myDownload.pdf"
   MsgBox "Download completed...", vbInformation, "Download status"
End Sub
pinkoAuthor Commented:
Sorry, didn't work... It doesn't download a file at all.
After execution, lngRetVal returns a value of -2147024891

I tried using both my proxy username/password and website username/password for the values of 'username:password', but neither worked.
pinkoAuthor Commented:
I did find a 3rd party VB component that allows you to pass the cookie from the internet explorer object to the download component! Which seems to solve my problem!

The component is: IP*Works! SSL Visual Basic Edition from /n software and you can find more info on this here:

As i found my own answer, i'm going to ask to have this question moved to a PAQ and my points refunded. If anyone has any objection to this, please let me know.
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.