AW: PDFs mit bestimmten Namen mailen
08.05.2019 09:34:44
Nepumuk
Hallo Sabbel,
teste mal:
Public Sub Mail_senden()
Dim objOutlook As Object, objMail As Object
Dim strFolder As String, strFileName As String
Dim avntAttachments() As Variant, vntItem As Variant
Dim ialngIndex As Long
strFolder = "D:\Test\Bestellung\" & Format$(Date, "yyyy") & _
"\" & Format(Date, "mmmm") & "\"
strFileName = Dir$(strFolder & Format$(Date, "dd-mm") & "*.*")
Do Until strFileName = vbNullString
ReDim Preserve avntAttachments(ialngIndex)
avntAttachments(ialngIndex) = strFolder & strFileName
ialngIndex = ialngIndex + 1
strFileName = Dir$
Loop
If ialngIndex = 0 Then
Call MsgBox("Keine Dateien gefunden.", vbExclamation, "Hinweis")
Else
Set objOutlook = CreateObject(Class:="Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = "name@provider.de"
.Subject = "Betreff"
.Body = "Hallo" & vbLf & vbLf & "im Anhang die Dateien." & _
vbLf & vbLf & "Gruß" & vbLf & "Sabbel"
For Each vntItem In avntAttachments
Call .Attachments.Add(vntItem)
Next
Call .Display 'Anzeigen
' Call .Send 'direkt senden
End With
Set objMail = Nothing
Set objOutlook = Nothing
End If
End Sub
Gruß
Nepumuk