ich brauche mal Rat.
Ich sende über eine Userform Mails an mehrere Empfänger gleichzeitig.
In der Userform kann ich auch Anlage der Mail einfügen.
Der Pfad u. Dateiname befindet sich dann in einem Label2.
Nun sende ich die Mail mit:
Private Sub cmdSend_Click()
Me.Hide
send_mail Label2, txtSubj, txtBody
Unload Me
End Sub
Sub send_mail(strFile As String, strSubj As String, strText As String)
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Sheets("Tabelle1").Columns("M").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "*@*" And cell.Offset(0, -1).Value = "ja" Then
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cell.Value
.Subject = strSubj
.Body = "Sehr geehrte/er Frau/Herr " & cell.Offset(0, -9).Value & vbNewLine & vbNewLine & _
strText & vbNewLine & vbNewLine
If strFile "" Then .Attachments.Add strFile
.Send 'Or use Display
'.Display
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Wenn ich jetzt aber mehr als eine Anlage auswähle, im Label2 seht z.B.:
C:\Auswertung.xls
D:\Statistik.doc
kann ich die Mail jedoch nicht senden.
Der Befehl: If strFile "" Then .Attachments.Add strFile
schein dabei das Problem zu sein was dieses nicht zulässt.
Was kann ich tun oder was muss ich ändern?
Danke u. Gruß
Marc