Hi,
I am looking for assistance with some VBA code that I have posted an extract of below.
I have been using this code for some time with no issues, however, my organisation recently updated from Excel 2010 to Excel 365 and the code that I have been running now has a "Run-time error '287': Application-defined or object-defined error" occurring at the line:
.HTMLBody = strbody & "<br>" & .HTMLBody
I can remove that line from the code and it presents the email with the standard Outlook Signature, but the text in the email body will be removed.
Could anyone please advise if they can see what needs to be updated (or changed) in the below code to make it work.
Thanks
I am looking for assistance with some VBA code that I have posted an extract of below.
I have been using this code for some time with no issues, however, my organisation recently updated from Excel 2010 to Excel 365 and the code that I have been running now has a "Run-time error '287': Application-defined or object-defined error" occurring at the line:
.HTMLBody = strbody & "<br>" & .HTMLBody
I can remove that line from the code and it presents the email with the standard Outlook Signature, but the text in the email body will be removed.
Could anyone please advise if they can see what needs to be updated (or changed) in the below code to make it work.
Thanks
VBA Code:
Sub EmailReport()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3></H3>" & _
"<br>" & "<br>" & _
"Please see attached Report." & "<br>" & "<br>" & _
"" & "<br>" & "<br>" & _
"Regards,"
With OutMail
.SentOnBehalfOfName = "123@abc.com"
.Display
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.HTMLBody = strbody & "<br>" & .HTMLBody
.Display
End With
On Error GoTo 0
With Application
.EnableEvents = 1
.Calculation = xlCalculationAutomatic
End With
OutMail.Display
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Last edited by a moderator: