I have the following VBA Code to create an E-Mail within an Excel spreadsheet:
Sub Test_EMail()
If ExitAll = False Then
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.HTMLbody
With OMail
.To = "test@test.de"
.Subject = "test"
.HTMLbody = "<p> Hello </p>" _
& vbCr & "<p> I want to have a specific line hight because this </p>" _
& vbCr & "<p> line height is too much space </p>" _
& vbCr & "<p> How I can decrease this line height? </p>"
End With
Set OMail = Nothing
Set OApp = Nothing
Else
End If
End Sub
The code itself works perfectly. However, when I see the E-Mail there is a big line height between the three sentences written with HTML.
If I try to go with this:
& vbCr & <p style="line-height: 50%">I want to have a specific line hight because this</p>
it also does not work which might be due to the mixing of a VBA and HTML Code.
Do you have any idea how I can change the line height in the E-Mail within the VBA code?
Since this is an HTML format email, the HTML opening and closing tags must also be inserted.
Dim body_ As String
body_= "<p> Hello </p>" _
& "<p> I want to have a specific line hight because this </p>" _
& "<p> line height is too much space </p>" _
& "<p> How I can decrease this line height? </p>"
.BodyFormat = olFormatHTML
.HTMLBody = "<html><head></head><body>" & body_ & "</body></html>"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.