AW: Email aus Excel senden mit Outlook
15.03.2006 15:40:09
Gustav
Hallo probier mal folgenden Code:
Sub Mail()
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, s
Sub 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)
s
Sub = 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
Jetzt nußt Du nur noch in Tabelle 1 folgende Spalten mit Leben füllen:
Spalte A: Mailempfänger
Spalte B: Dateiname incl. Pfad
Spalte C: Betreffzeile
Spalte D: Text
Viel Erfolg!
Gustav