如何在邮件正文的"1."前后添加制表符/空格?已试空格及Space(10)
嘿,我来帮你搞定邮件正文里给"1."前后加空格/制表符的问题!
你之前用普通空格或者Space(10)没效果,核心原因是HTML渲染时会自动合并多个连续的普通空格——哪怕你在VBA里拼了很多空格,最终到邮件的HTML正文里都会被缩成一个,自然达不到你想要的缩进效果。
给你几个可行的解决方案,直接修改你的VBA代码就行:
方案1:用HTML非换行空格( )
这是最常用的方法,每个 代表一个不会被合并的空格,你可以根据需要加多个:
sBodyStart = "<font size=""3"" face=""Calibri"" color=""black"">" & _ "Good Afternoon," & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "Please confirm and acknowledge the below by responding with the appropriate voting button." & "<br>" & "<br>" & _ " 1. Do not share this information." & "<br>" & "<br>" & _ ' 前面加4个非换行空格 "Please provide a response to this email using the voting buttons, no later than September 20, 2019. If you have any questions, please do not hesitate to reach out." & "<br>" & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "</font>"
方案2:用HTML制表符实体(	)
如果想要更像键盘Tab键的缩进效果,可以用	:
sBodyStart = "<font size=""3"" face=""Calibri"" color=""black"">" & _ "Good Afternoon," & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "Please confirm and acknowledge the below by responding with the appropriate voting button." & "<br>" & "<br>" & _ "	1. Do not share this information." & "<br>" & "<br>" & _ ' 前面加一个制表符 "Please provide a response to this email using the voting buttons, no later than September 20, 2019. If you have any questions, please do not hesitate to reach out." & "<br>" & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "</font>"
方案3:用CSS样式精确控制间距(更灵活)
如果需要更精准的间距大小,可以用<span>标签配合CSS的padding或margin:
sBodyStart = "<font size=""3"" face=""Calibri"" color=""black"">" & _ "Good Afternoon," & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "Please confirm and acknowledge the below by responding with the appropriate voting button." & "<br>" & "<br>" & _ "<span style='padding-left: 20px;'>1. Do not share this information.</span>" & "<br>" & "<br>" & _ ' 左边加20px间距 "Please provide a response to this email using the voting buttons, no later than September 20, 2019. If you have any questions, please do not hesitate to reach out." & "<br>" & "<br>" & "<br>" & vbCrLf & vbCrLf & _ "</font>"
你可以根据自己想要的缩进效果选其中一种,测试一下就能看到符合预期的排版啦!
内容的提问来源于stack exchange,提问作者rauf741
相关产品推荐
相关产品推荐

