AW: Hallo Klaus, hilfst Du mir bitte noch einmal
13.03.2014 08:28:53
Klaus
Hallo Larissa,
Du hattest es schon fast richtig! Die att2,3,4 Variablen deklariert, den Pfad zugewiesen ... was dir noch fehlte war, die Variablen an das Outlook-Makro zu übergeben und dort die Zeile "Attachement.Add" zu vervierfachen.
Ich habe es mir mal einfach gemacht und hänge die 4 Attachements direkt im Outlook-Makro an, statt sie per Variable zu übergeben:
Sub SendAllx()
Dim sSheet As String
Dim sText As String
Dim sTo As String
Dim sSubject As String
Dim lRow As Long
Dim myRng As Range
With Sheets("Pending")
lRow = .Cells(.Rows.Count, 7).End(xlUp).Row
sSubject = Sheets("NL_Text").Range("A2").Value
For Each myRng In .Range(.Cells(2, 7), .Cells(lRow, 7))
If myRng.Value = "x" Then
sTo = .Cells(myRng.Row, 8).Value
sText = .Cells(myRng.Row, 5) & "/br/ /br/" & Sheets("NL_Text").Range("B2").Value
sText = "/font face=""Calibri""/" & sText & "//font/"
Call SendMailOutlook(sSubject, sTo, sText)
End If
Next myRng
End With
End Sub
Private Sub SendMailOutlook(sSubject As String, sTo As String, sText As String)
Dim olApp As Object
Dim olOldBody As String
'Make Email
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.GetInspector.Display
olOldBody = .htmlBody
.To = sTo
.Subject = sSubject
.htmlBody = sText & olOldBody
.Attachments.Add Sheets("NL_Text").Range("C2").Value
.Attachments.Add Sheets("NL_Text").Range("D2").Value
.Attachments.Add Sheets("NL_Text").Range("E2").Value
.Attachments.Add Sheets("NL_Text").Range("F2").Value
End With
End Sub
Das HTML hab ich fix "maskiert", damit das Forum nicht verrückt spielt. Mach statt // wieder die größer-kleiner Zeichen hin, jaß
Grüße,
Klaus M.vdT.