In Deinem Fall ggf so:
Option Explicit
Const MYPATH As String = "c:\Test\"
Sub MacroMitDeinemFormularSteuerelementVerknuepfen()
Dim sText As String
sText = "Sehr ...." & vbNewLine
sText = sText & "foo bar bar foo" & vbNewLine & vbNewLine
sText = sText & "MfG"
Call SendSheetOutlook( _
"Betreffzeile", _
"EMailAnZeile_als_Emailadresse_getrennt_durch_Simikolon", _
"EmailCCZeile", _
sText)
End Sub
Private Sub SendSheetOutlook(sSubject As String, sTo As String, sCC As String, sText As String)
Dim olApp As Object
Dim AWS As String
Dim olOldBody As String
'define temporary Path and Filename
AWS = MYPATH & "\" & Format(Date, "YYYYMMDD") & "_" & Format(Time, "hhmmss") & "_" & _
WorksheetFunction.Substitute(ActiveWorkbook.Name, ".xlsm", "")
'export File as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=AWS, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
AWS = AWS & ".pdf"
'Make Email
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.GetInspector.Display
olOldBody = .htmlBody
.To = sTo
.cc = sCC
.Subject = sSubject
.htmlBody = sText & olOldBody
.Attachments.Add AWS
End With
'remove TEMP file
'********************************
'wenn du das PDF behalten möchtest, diese Zeile auskommentieren!
'sonst wird das temporäre PDF wieder gelöscht
'Kill AWS
'********************************
End Sub
|