none
Using my VB.net Code in VBA possible for email trigger? RRS feed

  • Question

  • Hello everyone

    I have written some code in VB 2012 and I have just found out I can use Outlook to trigger a macro. Now I had planned on using a macro to run this code seperately as a seprate .exe but I thought it would be much nicer to just write into  all into one macro. However I am being plagued by errors even when I add in every reference I can!

    Could anyone shed some light on this for me as I am not a programmer and have only recently been experimenting with VB.

    Thank you!

    Imports System.Windows.net
     Module Module1
     
     Sub Main()
            Dim web_client As New System.net.WebClient ' Make a web client
            Dim IE As Object
            IE = CreateObject("InternetExplorer.Application") 'Opens IE
            IE.Visible = True
            IE.Navigate ("IP Data acquisition") ' Navigates to the devices web browser
            Do While IE.busy    ' Wait for page to be loaded
                Application.DoEvents()
            Loop
            IE.Navigate ("Stop Test URL") 'Stop test
            Do While IE.busy    ' Wait for page to be loaded
                Application.DoEvents()
            Loop
            Try
                web_client.DownloadFile("File Download URL", "D:\Users\0001127\Documents\Uploads\file.exe")
                MessageBox.Show ("eDAQ File Download Complete")
                'Save file
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error Occured During Download. Please Try Again...", _
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End Try
            IE.Navigate ("Restart Test URL") 'Starts Test Again
            Do While IE.busy
                Application.DoEvents()
            Loop
            IE.Quit()
            IE = Nothing
        End Sub
    End Module

    Thursday, June 13, 2013 1:32 PM

Answers