A few days ago I started to receive this error when I ran this macro. I tried making Active X automatic, I tried re registering DLLs...I did a clean install on O365 STILL nothing. I have an existing file which has code that interacts with the Outlook.Application object. When I paste this code in there, it works. When I create a new workbook or use the existing file which the file resides in. This does not work. I haven't have the slightest clue why it works in one of my files but not this one. I really need this code to work but have ran out of options. Please help


Sub MailURL()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hello," & "<br>" \_
& "A new visit file has been posted. Please click" & "<A href='J:\Visit Reports Combined.xlsm'" & "> here </A>" & "to view the file." \_
& "<br>" & "Wieslaw"
On Error Resume Next
With OutMail
.to = " "
.Subject = "Daily Visit File Link"
.cc = ""
.HTMLBody = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
