Hey,
ich möchte gerne die letzte datei aus einem Ordner an eine Email anhängen.
Das Mail programm geht auch auf, nur leider hängt er keine Datei an...?
Dim strPath As String
Dim strFile As String
Dim strFileLast As String
Dim dtmFileLast As Date
strPath = "P:\ISK\PROJEKTE\ASE_PSM5\010 Loopcheck\030 Kaufmänische Abwicklung\Tagesmeldungen\" 'Aus dem Ordner die neueste Datei senden
If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
strFile = Dir$(strPath)
Do While strFile <> ""
If dtmFileLast < FileDateTime(strPath & strFile) Then
dtmFileLast = FileDateTime(strPath & strFile)
strFileLast = strFile
End If
strFile = Dir$()
Loop
Debug.Print strPath & strFileLast, dtmFileLast
Dim Nachricht As Object, OutlookApplication As Object
Set OutlookApplication = CreateObject("Outlook.Application")
Set Nachricht = OutlookApplication.CreateItem(0)
With Nachricht
.To = "xxxx@xxx.de"
.Subject = "Tagesmeldung vom " & Date
.attachments.Add dtmFileLast
.Body = "Hallo Moritz, anbei sende ich dir die Aktuelle Tagesmeldung."
.Display
'.Mail.Send
End With
Set OutlookApplication = Nothing
Set Nachricht = Nothing
|