Hello Microsoft Team,
When I try to send an e-mail in Excel via VBA using Outlook, I get the error message: "An error has occurred: Object creation not possible through ActiveX component", It works via the Outlook application. If I switch to the New Outlook, the error message appears.
For testing, I used the following coding in Excel:
Sub SendEmail(what_address As String, subject_line As String, mail_body As String)
Dim olApp As Object
Dim olMail As Object
On Error GoTo ErrorHandler
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
olMail.To = what_address
olMail.Subject = subject_line
olMail.body = mail_body
olMail.Send
Exit Sub
ErrorHandler:
MsgBox "An error occurred: " & Err.Description
End Sub
Thank you and best regards
Torsten