Sub
pdf_per_mail()
Dim
pdf
As
String
pdf = pdf_erstellen
Call
permail(pdf)
Kill (pdf)
End
Sub
Function
pdf_erstellen()
Dim
pdf
As
String
Dim
sep
As
String
sep = Application.PathSeparator
pdf = ThisWorkbook.Path & sep & ThisWorkbook.Name &
"_"
&
Date
& Format(Time,
"hhmm"
) &
".pdf"
On
Error
Resume
Next
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdf, _
Quality:=xlQualityStandard, IncludeDocProperties:=
True
, IgnorePrintAreas:=
False
, OpenAfterPublish:=
False
On
Error
GoTo
0
pdf_erstellen = pdf
End
Function
Sub
permail(
ByVal
pdf
As
String
)
Dim
objOutlook
As
Object
Dim
objMail
As
Object
Dim
myAttachments
Set
objOutlook = CreateObject(
"Outlook.Application"
)
Set
objMail = objOutlook.CreateItem(0)
Set
myAttachments = objMail.Attachments
With
objMail
.
To
=
"office@dfinvesting.com"
.Subject =
"Excelpedia + youtube"
.Body =
"Sehr geehrte Damen und Herren, "
& vbNewLine _
& vbNewLine _
&
"Danke für das Video zum automatischen Versenden von mails."
& vbNewLine _
&
"lg"
myAttachments.Add pdf
.Display
End
With
End
Sub