Gruppe
Extern
Problem
An die in Zelle B1 genannte Adresse soll eine Email mit Anlage versandt werden, wobei die Nachricht zu Nachverfolgung gekennzeichnet werden soll.
StandardModule: Modul1
Sub SendAndSetFlag()
Dim oOL As Object
Dim oOLMsg As Object
Dim oOLRecip As Object
Dim oOLAttach As Object
Dim sFile As String, sRec As String, sSub As String
Dim sBody As String
Set oOL = CreateObject("Outlook.Application")
sRec = Range("B1").Value
sFile = Range("B2").Value
If Dir(sFile) = "" Then
Beep
MsgBox "Datei wurde nicht gefunden!"
Exit Sub
End If
sSub = "Textdatei"
Set oOLMsg = oOL.CreateItem(0)
With oOLMsg
Set oOLRecip = .Recipients.Add(sRec)
.Subject = sSub
Set oOLAttach = .Attachments.Add(sFile)
.FlagStatus = olFlagMarked
.Send
oOLRecip.Resolve
End With
Set oOL = Nothing
End Sub