VBA - Outlook Email.HTMLBody 行距?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15098719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 19:47:31  来源:igfitidea点击:

VBA - Outlook Email.HTMLBody Line spacing?

emailvbaoutlookspacing

提问by Kirbtheman

his is a small problem but is confusing me. I am automating an email to be sent from excel. The below code, for some reason, makes the last line have larger than normal spacing:

他是一个小问题,但让我感到困惑。我正在自动化从 excel 发送的电子邮件。由于某种原因,下面的代码使最后一行的间距大于正常间距:

Sub emailspacing()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
    .HTMLBody = "<p style='font-family:calibri;font-size:14.5'>Thanks for your help</p>"
    .display
End With

Whereas, when I remove the P style part, the email is generated with perfect line spacing???

然而,当我删除 P 样式部分时,生成的电子邮件具有完美的行距???

Sub emailspacing()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
    .HTMLBody = "Thanks for your help"
    .display
End With

Does anyone know a way to combine the stylised HTML text with normal line spacing?

有谁知道将风格化的 HTML 文本与正常的行间距结合起来的方法?

采纳答案by Kirbtheman

Cracked it! This needed to be added to the p style:

破解了!这需要添加到 p 样式中:

margin-bottom:.0001pt;

边距底部:.0001pt;