Gruppe
Extern
Problem
In einer Excel-Tabelle habe ich spaltenweise folgende Angaben: Email-Adressen, Dateinamen, Betreff, Text Wie kann ich auf Basis dieser Daten Outlook starten und die Emails mit den genannten Anlagen und Angaben in den entsprechenden Feldern versenden?
StandardModule: basMain
Sub Verteilen()
Dim oOL As Object
Dim oOLMsg As Object
Dim oOLRecip As Object
Dim oOLAttach As Object
Dim iRow As Integer, iCounter As Integer
Dim sFile As String, sRec As String, sSub As String
Dim sBody As String
Dim bln
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
bln = Application.DisplayStatusBar
iRow = Cells(Rows.Count, 1).End(xlUp).Row
Set oOL = CreateObject("Outlook.Application")
For iCounter = 2 To iRow
sRec = Cells(iCounter, 1)
sFile = Cells(iCounter, 2)
sSub = Cells(iCounter, 3)
sBody = Cells(iCounter, 4)
Application.StatusBar = "Sende Datei " & sFile & " an " & sRec & "..."
Set oOLMsg = oOL.CreateItem(0)
With oOLMsg
Set oOLRecip = .Recipients.Add(sRec)
.Subject = sSub
.Body = sBody & vbLf & vbLf
Set oOLAttach = .Attachments.Add(sFile)
.Send
End With
oOLRecip.Resolve
Next iCounter
Set oOL = Nothing
Application.StatusBar = False
Application.DisplayStatusBar = bln
End Sub