I have a VBS code set to open, refresh all data connection, save and close all of my excel files and a .bat file that calls on that VBS code with task scheduler at 8:00 AM.
When I come in, I have a VBA in excel that I push when I come to work that sends those files to correct recipients. I cannot use task scheduler to send an email because of server restrictions (I already checked with IT and it was a dead end).
I am trying to see how do I convert the VBA to VBS so I can use a .bat file with task scheduler to circumvent the server restriction.
Sub Test()
Dim strLocation As String
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
''Change to Your Email Address
.To = "my email"
.CC = ""
.BCC = ""
''Add you own Subject and Message to the body
.Subject = "Email test to multiple email boxes"
.Body = "Hello World!"
''Update the path to match where your file is
strLocation = ("C:\Users\rock\Desktop\" & "Base.xlsx")
.Attachments.Add (strLocation)
.Display
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Any help would be appreciated.
When I come in, I have a VBA in excel that I push when I come to work that sends those files to correct recipients. I cannot use task scheduler to send an email because of server restrictions (I already checked with IT and it was a dead end).
I am trying to see how do I convert the VBA to VBS so I can use a .bat file with task scheduler to circumvent the server restriction.
Sub Test()
Dim strLocation As String
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
''Change to Your Email Address
.To = "my email"
.CC = ""
.BCC = ""
''Add you own Subject and Message to the body
.Subject = "Email test to multiple email boxes"
.Body = "Hello World!"
''Update the path to match where your file is
strLocation = ("C:\Users\rock\Desktop\" & "Base.xlsx")
.Attachments.Add (strLocation)
.Display
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Any help would be appreciated.