Ich versuche mit folgendem Code ein pdf an die Mail zu hängen
Option Explicit
Sub Schaltfläche1_Klicken()
Dim OutApp As Object
Dim OutMail As Object
Dim Attachments As Object
Dim Betreff As String
Dim DateiName As String
Dim Text As String
Dim ObjMail As Object
Dim strHTMLBody As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Call TempSave.ZwischenSpeichern(ActiveWorkbook.Name)
Betreff = (Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5))
DateiName = (Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)) & "pdf"
Text = "Hi all " & vbCrLf & vbCrLf
Text = Text & "Please book and pay this invoice." & vbCrLf
Text = Text & "PO " & Sheets("Grund").Range("B14") & vbCrLf & vbCrLf
Text = Text & "Many thanks and best regards" & vbCrLf & vbCrLf
On Error Resume Next
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = Betreff & " PO " & Sheets("Grund").Range("B14")
.Body = Text
.Attachments.Add = DateiName
ObjMail.HTMLBody = strHTMLBody & ObjMail.HTMLBody
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Excel und pdf sind im selben verzeichniss
Warum wird das pdf nicht angehängt?
Gruss
Walter