Hallo,
schau mal, ob das so klappt:
Sub Mail_Senden_mit_PDF()
'Sendet Mail mit integriertem Bereich als Bild mit Signatur
'Das Bild wird über das Kürzel ~ im Text platziert
Dim WSh As Worksheet, WkS As Worksheet
Dim sMailtext As String, sBild As String, sSignatur As String
Dim sBer As String, sDateiName As String
Dim P As Integer, iEinf As Integer
sDateiName = ThisWorkbook.FullName
sDateiName = Left$(sDateiName, InStrRev(sDateiName, ".")) & "pdf"
'<<<Tabellenblatt anpassen>>>
ThisWorkbook.Sheets("Tabelle1").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=sDateiName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
sBer = "A20:K33" 'Kopierbereich
Set WSh = ThisWorkbook.Sheets("Tabelle1") 'Blatt mit Maildaten
On Error Resume Next
'Bereich kopieren
Do
WSh.Range(sBer).CopyPicture Appearance:=xlScreen, Format:=xlBitmap
If err.Number = 0 Then Exit Do
err.Clear
Loop
With CreateObject("Outlook.Application").CreateItem(0)
.BodyFormat = 2 'HTML-Format, Angabe optional
.Subject = "Crate and Weight Size" 'Betreff
.To = "Mail@test.de" 'Empfänger
sMailtext = "Hi ," & vbLf & vbLf & "Crate and weight size for " _
& WSh.Range("F20").Value & ":" & vbLf & vbLf
.GetInspector: sSignatur = .HTMLBody 'Signatur holen
.HTMLBody = Replace(sMailtext, vbLf, "<br>") & sSignatur
.Display
iEinf = Len(sMailtext) - 1 'Grafik Einfügestelle
With .GetInspector.WordEditor.Application.Selection
.Start = iEinf: .End = iEinf
.Paste 'Grafik in Mail einfügen
End With
If Dir$(sDateiName) <> "" Then
.Attachments.Add sDateiName 'Anlage anfügen
End If
End With
End Sub
viele Grüße
Karl-Heinz
|