用Excel VBA创建的电子邮件(HTML)中的行高 [英] Line height in an E-Mail (HTML) created with Excel VBA

查看:50
本文介绍了用Excel VBA创建的电子邮件(HTML)中的行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下VBA代码,可以在Excel电子表格中创建电子邮件:

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

代码本身可以完美运行.但是,当我看到电子邮件时,用HTML编写的三个句子之间的行高很大.

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.

如果我尝试这样做:

& vbCr & <p style="line-height: 50%">I want to have a specific line hight because this</p>

它也不起作用,可能是由于VBA和HTML代码混合使用了.

it also does not work which might be due to the mixing of a VBA and HTML Code.

您是否知道如何在VBA代码中更改电子邮件中的行高?

Do you have any idea how I can change the line height in the E-Mail within the VBA code?

推荐答案

由于这是HTML格式的电子邮件,因此还必须插入HTML开头和结尾标签.

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>"

这篇关于用Excel VBA创建的电子邮件(HTML)中的行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆