Option Explicit
Sub SendOutlookMail_LateBinding()
Dim olApp As Object
Dim olMail As Object
' Outlook-Instanz mittels Late Binding starten oder nutzen, falls bereits geöffnet.
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
If olApp Is Nothing Then
MsgBox "Outlook konnte nicht gestartet werden!", vbExclamation
Exit Sub
End If
' Neues E-Mail-Objekt erstellen (olMailItem = 0)
Set olMail = olApp.CreateItem(0)
With olMail
' Empfänger festlegen
.To = "empfaenger@example.com"
.CC = "kopie@example.com"
.BCC = "blindkopie@example.com"
' E-Mail-Betreff und Inhalt definieren
.Subject = "Betreff der E-Mail"
.Body = "Dies ist der Inhalt der E-Mail."
' Alternativ: HTML formatierten Inhalt verwenden
' .HTMLBody = "Willkommen
Dies ist eine HTML-E-Mail.
"
' E-Mail anzeigen (zum Testen); alternativ mit .Send direkt versenden.
.Display
End With
End Sub