Hi everyone,
I'm at a bit of a loss with this one as the code I'm using I've used before without issue. My goal is to have Excel move a worksheet to a new workbook, save that file and send it and then kill the file. All the code is working apart from the code to send an email, when I've took out of this code from my main module and ran it independently and nothing happens. Any help will be massively appreciated.
I'm at a bit of a loss with this one as the code I'm using I've used before without issue. My goal is to have Excel move a worksheet to a new workbook, save that file and send it and then kill the file. All the code is working apart from the code to send an email, when I've took out of this code from my main module and ran it independently and nothing happens. Any help will be massively appreciated.
Code:
Sub System_Issue_Mail()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hi" & vbNewLine & vbNewLine & _
"Please find attached a new archived certificate request." & vbNewLine & _
"Thanks"
On Error Resume Next
With OutMail
.To = "System.support@.org.uk"
.CC = ""
.BCC = ""
.Subject = "A New System Issue has been raised by user" & usr
.Body = ""
.Attachments.Add ("C:\Users\" & usr & "\Documents\TEMPFILETBR.xlsx")
.Display '.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub