AW: Excelinhalt nach Outlook Besprechungsanfrage
09.07.2019 14:24:34
Heidi
Hallo Peter,
dies hier ist der komplette Code, habe bei Body auch HTMLBody geändert, aber geht leider nicht.
Option Explicit
Public Sub Mail_Outlook_With_Signature_Html_9()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(1)
With OutMail
.Display
.Subject = "Jahr_Monat_Tag_Kick-off_8Dxx-x - Kennwort/ Land - LIPROGIS XXXX Circuit - _
Einladung"
.HTMLBody = "Guten Tag, mein Name ist Heidi Martin und ich weiß nix mehr!
" & _
"ich möchte Sie zum Eng. Handshake zu folgendem Projekt einladen." & _
RangeToHtml("Einladung_Kick-Off", "A1:I62") & .HTMLBody
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Private Function RangeToHtml( _
ByVal pvstrWorksheetName As String, _
ByVal pvstrRangeAddress As String) As String
Dim objFilesytem As Object, objTextstream As Object
Dim objPublishObject As PublishObject
Dim strFilename As String, strTempText As String
strFilename = Environ$("temp") & "\" & _
Format(Now, "dd-mm-yy_hh-mm-ss") & ".htm"
Set objPublishObject = ThisWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=strFilename, _
Sheet:=pvstrWorksheetName, _
Source:=pvstrRangeAddress, _
HtmlType:=xlHtmlStatic)
Call objPublishObject.Publish(Create:=True)
Set objFilesytem = CreateObject("Scripting.FileSystemObject")
Set objTextstream = objFilesytem.GetFile(strFilename).OpenAsTextStream(1, -2)
strTempText = objTextstream.ReadAll
Call objTextstream.Close
RangeToHtml = Replace(strTempText, "align=center x:publishsource=", _
"align=left x:publishsource=")
Set objPublishObject = Nothing
Set objTextstream = Nothing
Set objFilesytem = Nothing
Call Kill(PathName:=strFilename)
End Function