AW: Hyperlink per mail aus Dokument heraus?
09.12.2018 12:33:33
Sepp
Hallo MaBlu,
Modul Modul2
Option Explicit
'Aktive Arbeitsmappe versenden
Sub sendAktiveWorkbook()
Call Outlook_Mail_Link
End Sub
'Alle offenen Arbeitsmappen versenden
Sub sendAllWorkbooks()
Call Outlook_Mail_Link(True)
End Sub
Sub Outlook_Mail_Link(Optional ByVal AllWorkbooks As Boolean = False)
Dim objOL As Object, objMail As Object, objWB As Workbook
Dim strSignature As String, strBody As String
Set objOL = CreateObject("Outlook.Application")
Set objMail = objOL.CreateItem(0)
On Error Resume Next
strBody = "Hallo...,<br><br>" & "Anbei die Datei(en).<br><br>"
If AllWorkbooks Then
For Each objWB In Application.Workbooks
If Len(Dir(objWB.FullName, vbNormal)) Then _
strBody = strBody & "<a href=""file://" & objWB.FullName & """>" & _
objWB.Name & "</a><br>"
Next
Else
If Len(Dir(ActiveWorkbook.FullName, vbNormal)) Then _
strBody = strBody & "<a href=""file://" & ActiveWorkbook.FullName & """>" & _
ActiveWorkbook.Name & "</a><br>"
End If
With objMail
.GetInspector
strSignature = "<br><br>" & .HTMLBody
.To = "empfänger@domain.com"
.CC = ""
.BCC = ""
.Subject = "Hier kommt die Mail!"
.HTMLBody = strBody & strSignature
.Display 'or use .Send
End With
On Error GoTo 0
Set objMail = Nothing
Set objOL = Nothing
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0